Like this:
#include <iostream>
#include <string>
int main()
{
for (std::string line; std::getline(std::cin, line); )
{
if (line.empty())
{
// handle blank input
}
std::cout << "You said: " << line << "\n";
}
}
This doesn't trim whitespaces yet; that can be done easily by modifying line
at the beginning of the loop, e.g. using this code and adding trim(line);
at the beginning.