Like I have a stringstream variable contains "abc gg rrr ff"
When I use >> on that stringstream variable, it gives me "abc". How can I get the remaining string: " gg rrr ff"? It seems neither str() nor rdbuf() does this work.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
std::getlineto get the rest of the string from the stream:Output:
Demo : http://www.ideone.com/R4kfV
There is an overloaded
std::getlinefunction in which a third parameter takes a delimiter upto which you can read the string. See the documentation ofstd::getline: