input string with space in c++ code example
Example 1: c++ reading string
#include <iostream>
#include <string>
string str;
getline(cin, str);
//str contains line
Example 2: does cin read whitespace?
cin does not read white space.
#include <iostream>
#include <string>
string str;
getline(cin, str);
//str contains line
cin does not read white space.