Strings and Spaces.

When doing an extremely simple code such as this:

1
2
3
cout << "Enter a string:\n";
	cin >> a;
	cout << a << "\n";


If I type in more than one word for a; say I typed in:
Hello World!


It would only cout
Hello


Do strings always do this?
Is there a way to overcome it?
Am I doomed forever?
>> gets until whitespace.

If you want the whole line, use getline:
1
2
//cin >> a;  // boo
getline(cin,a); // yay! 
Ah, thank you so much!

Massive help, cheers!
Topic archived. No new replies allowed.