📜  在字符向量 C++ 代码示例上拆分字符串

📅  最后修改于: 2022-03-11 14:44:50.706000             🧑  作者: Mango

代码示例1
string s, tmp; 
stringstream ss(s);
vector words;

// If there is one element (so komma) then push the whole string
if(getline(ss, tmp, ',').fail()) {
  words.push_back(s);
}
while(getline(ss, tmp, ',')){
    words.push_back(tmp);
}