根据空格split
string str = "abc def,ghi"; stringstream ss(str); string token; while (ss >> token) cout<<token<<endl;
output:
abc
def,ghi
根据指定字符split
vector<string> result; string tmp; string toBeSplited; stringstream ss(toBeSplited); while(getline(ss, tmp, '/')) { result.push_back(tmp); }