#include <sstream>
#include <iostream>
using namespace std;
int main()
{
string str = "talk,is,cheap";
stringstream ss(str);
string token;
while (getline(ss, token, ','))
{
cout << token << endl;
//talk
//is
//cheap
}
}
使用stringstream和getline()实现指定字符分割字符串
最新推荐文章于 2023-10-08 14:15:41 发布