My code looks like this,
string aString;
cin >> aString;
cout << \"This is what cin gets:\" << aString << endl;
getline(cin, aString)
this is what I get:
std::string str;
std::cin >> str; //hello world
std::cout << str; //hello
this is because the stream operator tokenizes on white space
std::string str;
std::getline(std::cin, str); //hello world
std::cout << str; //hello world
you get the full line, getline() works until it find the first end of line and returns that value as a string.
However when tokenizing, if there are characters (for example a '\n') left in the stream then these will be accessed when getline is called, you will need to clear the stream.
std::cin.ignore();