標題:
stringstream 字串串流
[打印本頁]
作者:
陳品肇
時間:
2019-7-20 12:54
標題:
stringstream 字串串流
試利用 stringstream 型別, 將多個字串串起來,
再利用 str() 函式將物件中的字串帶出來.
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string str1="abc";
string str2="狗咬豬";
ss<<str1<<str2<<"...";
cout<<ss.str()<<endl;
system("pause");
return 0;
}
複製代碼
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string str1="abc";
string str2="狗咬豬";
string str;
ss<<str1<<str2<<"...";
ss>>str;
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
作者:
曲書辰
時間:
2019-7-20 14:04
本帖最後由 曲書辰 於 2019-7-20 14:06 編輯
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream a;
string b="abc";
string c="狗咬豬";
a<<b<<c<<"....";
string d;
a>>d;
cout<<d<<endl;
system("pause");
return 0;
}
複製代碼
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream a;
string b="abc";
string c="狗咬豬";
a<<b<<c<<"....";
cout<<a.str()<<endl;
system("pause");
return 0;
}
複製代碼
作者:
吳孟書
時間:
2019-7-20 14:04
#include<iostream>
#include<cstdlib>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
string str1="我";
string str2="是";
ss<<str1<<str2<<"...";
cout<<ss.str()<<endl;
system("pause");
return 0;
}
複製代碼
#include<iostream>
#include<cstdlib>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
string str1="我";
string str2="是";
string str;
ss<<str1<<str2<<"...";
ss>>str;
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
作者:
湯郡一
時間:
2019-7-20 14:07
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string str1="我是";
string str2="...";
ss<<str1<<str2<<"...";
cout<<ss.str()<<endl;
system("pause");
return 0;
}
複製代碼
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string str1="我是";
string str2="...";
string str;
ss<<str1<<str2<<"...";
ss>>str;
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
作者:
田宇任
時間:
2019-7-20 14:08
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
strng str1="123";
string str2="abc";
string str;
ss<<str1<<str2<<"...";
ss>>str;
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string str1="123";
string str2="abc";
ss<<str1<<str2<<"...";
cout<<ss.str()<<endl;
system("pause");
return 0;
}
複製代碼
作者:
吳孟修
時間:
2019-7-20 14:08
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string stra="abc";
string strb="狗咬豬";
ss<<stra<<strb<<"...";
cout<<ss.str()<<endl;
system("pause");
return 0;
}
複製代碼
#include<iostream>
#include<sstream>
#include<cstdlib>
using namespace std;
int main()
{
stringstream ss;
string stra="abc";
string strb="狗咬豬";
string str;
ss<<stra<<strb<<"...";
ss>>str;
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
作者:
王瑞喻
時間:
2019-7-20 14:08
#include<iostream>
#include<cstdlib>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
string str1="abc";
string str2="狗咬豬";
ss<<str1<<str2<<"...";
cout<<ss.str()<<endl;
system("pause");
return 0;
}
複製代碼
#include<iostream>
#include<cstdlib>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
string str1="abc";
string str2="狗咬豬";
string str;
ss<<str1<<str2<<"...";
ss>>str;
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
作者:
洪寬瀧
時間:
2019-7-20 14:09
#include<iostream>
#include<cstdlib>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
string str1="unc";
string str2="狗咬豬";
ss<<str1<<str2<<"............";
cout<<ss.str()<<endl;
system("pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<sstream>
using namespace std;
int main()
{
stringstream ss;
string str1="unc";
string str2="狗咬豬";
string str;
ss<<str1<<str2<<"............";
ss>>str;
cout<<str<<endl;
system("pause");
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2