How do you clear a stringstream variable?

For all the standard library types the member function empty() is a query, not a command, i.e. it means “are you empty?” not “please throw away your contents”. The clear() member function is inherited from ios and is used to clear the error state of the stream, e.g. if a file stream has the error … Read more

Reading getline from cin into a stringstream (C++)

You are almost there, the error is most probably1 caused because you are trying to call getline with second parameter stringstream, just make a slight modification and store the data within the std::cin in a string first and then used it to initialize a stringstream, from which you can extract the input: 1. Assuming you have included: