Originally Posted by
Labmouse
stupid question I know(only just starting out in c++)but how do you read in a sentence and print it out.Im using the string varible but can only ever print out the first word and not the second.I think it might have something to do with the spaces between the words?Any help much appreciated,
Labmouse
use the getline function. eg,
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string full_name;
cout << "Enter your full name: ";
getline( cin, full_name );
cout << "Hello " << full_name << endl;
}