C++ sstream Library
C++ sstream Library
The <sstream> library has classes that let you use a string as a stream (a flow of data). You can write to a string and read from a string, in the same way as you use cout and cin.
String streams are useful when you want to split a string into words, convert between text and numbers, or build a string from many values.
| Name | Description |
|---|---|
| stringstream | A stream that you can both write to and read from, which keeps its data in a string |
| istringstream | A stream that reads from a string, like cin reads from the keyboard |
| ostringstream | A stream that writes to a string, like cout writes to the screen |
| str() | Returns the content of a string stream as a string, or replaces it with a new string |
Related Pages
C++ How To Count Words in a String