OK, so you want to accept empty strings as well.
The simplest way is to use getline instead of >>
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
while (getline(cin, s))
cout << "\"" << s << "\"\n";
}
The difference, of course, is that this will read an entire line into a string, not up to first whitespace.
Also, if there are lots of cin >> 's in the program, you should empty the input buffer after using >> and before using getline:
Code:
#include <limit>
...
cin.ignore(numeric_limits<streamsize>::max(), '\n');