Wednesday, April 6, 2011

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

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

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

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

  • 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.
    nbolton : According to Einstein, you don't understand something unless you can explain it in one sentence.
  • Use the .str()-method.

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

    rmeador : +1 because you provided a link, unlike the other equivalent answers.
  • You might be able to use this library, but I could be wrong

0 comments:

Post a Comment