string按空格分割

来源:互联网 发布:mac苹果diy显示器 编辑:程序博客网 时间:2024/06/01 19:04
#include <iostream>
#include <string>
#include <sstream>
using namespacestd;
int main()
{
string str="12 13 14 15";
string buf;
stringstream ss(str); // 字符流ss
while (ss >> buf)
{
cout<<buf<<endl;
}
return 0;
}