views:

2117

answers:

4

How do I convert from std::stringstream to std::string in C++?

Do I need to call a method on the string stream?

+2  A: 

From memory, you call stringstream::str() to get the std::string value out.

Timo Geusch
+14  A: 

yourStringStream.str()

Tyler McHenry
SO meta-question: Why is it that the answers to the simplest questions always get so many upvotes compared to answers to more involved/obscure questions? I suppose maybe it's just that more people read the simple questions.
Tyler McHenry
According to Einstein, you don't understand something unless you can explain it in one sentence.
nbolton
+4  A: 

Use the .str()-method.

http://www.cppreference.com/wiki/io/sstream/str

Emil H
+1 because you provided a link, unlike the other equivalent answers.
rmeador
A: 

You might be able to use this library, but I could be wrong

Chris