<aside> 💡 stringstream
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main() {
// ifstream
ifstream in("file.txt");
string word;
while(in > word) {
cout << word << endl;
}
// istringstream
string data = "123 456";
istringstream iss(data);
int num1, num2;
iss >> num1 >> num2;
cout << num1 << num2 << endl;
// ostringstream
ostringstream oss;
oss << "Hello " << "World";
cout << oss.str() << endl;
//stringstream
stringstream ss;
ss << "123 456";
int num1, num2;
iss >> num1 >> num2;
cout << num1 << num2 << endl;
cout << ss.str() << endl;
return 0;
}
</aside>