標題:
清空 stringstream
[打印本頁]
作者:
陳品肇
時間:
2019-5-4 15:32
標題:
清空 stringstream
ss.str("");
ss.clear();
[attach]6412[/attach]
#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;
}
複製代碼
作者:
陳柏霖
時間:
2019-5-4 17:20
#include<iostream>
#include<cstdlib>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
string n1="123" ,n2="456" ,n3 ,n4;
ss<<n1;
ss>>n3;
cout<<"ss:"<<ss.str()<<endl;
cout<<"n3:"<<n3<<endl;
ss.str("");
ss.clear();
ss<<n2;
ss>>n4;
cout<<"ss:"<<ss.str()<<endl;
cout<<"n4:"<<n4<<endl;
system("pause");
return 0;
}
複製代碼
作者:
譚詩澐
時間:
2019-5-4 17:20
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string str1="123", str2="456", str3, str4;
ss<<str1;
ss>>str3;
cout<<ss.str()<<endl;
ss.str("");
ss.clear();
ss<<str2;
ss>>str4;
cout<<ss.str()<<endl;
system("pause");
return 0;
}
複製代碼
作者:
蔡依宸
時間:
2019-5-4 17:21
#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;
}
複製代碼
作者:
戴唯陞
時間:
2019-5-4 17:25
#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;
複製代碼
作者:
蔡季庭
時間:
2019-5-4 17:25
#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;
}
複製代碼
作者:
戴偉宸
時間:
2019-5-4 17:26
#include<iostream>
#include<cstdlib>
#include<sstream>
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://seed.istak.org.tw/)
Powered by Discuz! 7.2