Stringstream

Hi,

Im a bit confused about stringstream and I wana get it right. I understood it that its the same thing as function atoi in C. Am i right? And if im not pls explain it to me. Tnx :)
I understood it that its the same thing as function atoi in C.

stringstream is much more than and quite different from atoi.

stringstream is an iostream where a string is used to hold the data instead of the data being transferred to/from a file.
http://www.cplusplus.com/reference/sstream/stringstream/?kw=stringstream

Anything you can do with an istream or an ostream, you can do with an stringstream.
stringstreams can be useful for parsing input from a getline operation. Or they can be used to build a complex string using output operators.
1
2
3
4
  FOO foo;   // FOO overloads the << operator
  stringstream  ss;
  ss << foo;  // Write FOO to the stringstream.  FOO doesn't know or care that we're using a stringstream.
  cout << ss.str() << endl; // Output the accumulated string 





Ty sooo much.
Topic archived. No new replies allowed.