![]() |
VOOZH | about |
A stringstream is a part of the C++ Standard Library, defined in the <sstream> header file. It allows us to read from and write to strings like they are streams.
It lets us take a string and extract data from it (like from cin), It also lets us build strings by inserting data into it (like into cout).
There are three types of string stream classes in C++:
Class | Purpose |
|---|---|
stringstream | Both input and output |
istringstream | Input only (like cin) |
ostringstream | Output only (like cout) |
Integer: 123
String: 456
C++ is powerful
Name: John, Age: 25
Before clearing: Hello, world! After clearing and reuse: New data here!