標題:
清空 stringstream
[打印本頁]
作者:
tonyh
時間:
2018-8-27 20:13
標題:
清空 stringstream
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;
}
複製代碼
作者:
洪翊展
時間:
2018-8-27 20:44
#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;
}
複製代碼
作者:
李沛昂
時間:
2018-9-2 20:17
#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;
}
複製代碼
作者:
戴嘉禾
時間:
2018-9-3 18:42
#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;
}
複製代碼
作者:
啓銓
時間:
2018-11-26 19:31
#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;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2