6

I have a stream object std::stringstream and I want to get whatever it currently has as a std::string. Is that possible? I want it for output to my graphic console.

1 Answer 1

7

You can use the stringstream::str() method for that: https://cplusplus.com/reference/sstream/stringstream/str/

Sign up to request clarification or add additional context in comments.

1 Comment

Note that stringstream::str() returns a copy of the string, not a reference to it. To update or clear stringstream's string, use stringstream::str(string).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.