C++ examples for Data Type:string
Read string with std::cin.getline()
#include <iostream> int main() // w ww .j av a 2s . c o m { char name[50]; char quest[80]; char velocity[80]; std::cout << "\nWhat is your name? "; std::cin.getline(name, 49); std::cout << "\nWhat is your quest? "; std::cin.getline(quest, 79); std::cout << "\nWhat is the velocity? "; std::cin.getline(velocity, 79); std::cout << "\nName: " << name << std::endl; std::cout << "Quest: " << quest << std::endl; std::cout << "Velocity: " << velocity << std::endl; return 0; }