stringstream
stringstream builds and parses text like a file.
Example
#include <iostream>
#include <sstream>
int main() {
std::stringstream ss;
ss << "x=" << 42 << ";";
std::cout << ss.str() << "\n";
std::istringstream in("3 4 5");
int a, b, c; in >> a >> b >> c;
std::cout << a + b + c << "\n";
return 0;
}Result
x=42; 12
Exercise
Build text.
std:: ss;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.