+ 1
#include <iostream> #include <sstream> using namespace std; int main() { // str() overwrite stringstream ss; string s="hello my friend"; ss.str(s); cout<<"1:"<<ss.str()<<endl; s = "good morning my friend"; ss.str(s); cout<<"2:"<<ss.str()<<endl; // << append stringstream ss2; s="hello my friend"; ss2<<s; cout<<"3:"<<ss2.str()<<endl; s = "good morning my friend"; ss2<<s; cout<<"4:"<<ss2.str()<<endl; return 0; }
4th Jul 2022, 5:04 AM
Bob_Li
Bob_Li - avatar