if i wanted to cin a string
but the string consisted of multiple words, how would i do it
wont do the job if i enter a string like Good morning everyone.
int main ()
cin >> f;
cout << f;
because it takes the space as a delimiter.
any ideas... i know this is a stupid question.. early morning mind isnt working :D
i got it
just in case anyone has the same question in the future. :)
using member function getline for char* type strings.
Or, for reading a line of input into a string type:
getline(cin, text, '\n');
Note that for both cin.getline() and getline(), you can read in multiple lines of text by changing the "delimiter" which is the 3rd parameter. If you use a '#' as the third parameter, input will continue until those functions find a '#' sign in the input, which you can insert after say the 5th line of input.