本帖最後由 王瑞喻 於 2020-7-7 09:35 編輯
ss.str("");
ss.clear();
- #include<iostream>
- #include<sstream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- stringstream ss;
- string str1="123",str2="456",str3,str4;
- ss<<str1;
- cout<<"ss: "<<ss.str()<<endl;
- ss>>str3;
- cout<<"str3: "<<str3<<endl;
- ss.str("");
- ss.clear();
- ss<<str2;
- cout<<"ss: "<<ss.str()<<endl;
- ss>>str4;
- cout<<"str4: "<<str4<<endl;
- system("pause");
- return 0;
- }
複製代碼 |