首页 > 代码库 > C++中如何split字符串(转)

C++中如何split字符串(转)

#include <iostream>#include <sstream>#include <string>using namespace std;int main(){    string s("Somewhere down the road");    istringstream iss(s);             while (iss)    {        string sub;        iss >> sub;        cout << "Substring: " << sub << endl;    }        system("pause");}

效果图: