Linki powyżej, w zasadzie powinne wystarczyć, ale linki, jak to linki, lepiej, żeby wszystko co potrzebne do rozwiązania było na forum(za fluentcpp.com + trim z odmętów netu:)):
std::vector<string> split_twice(const std::string& str, char delim, char delim2) {
std::vector<string> cont;
std::stringstream ss(str);
std::string token;
while (std::getline(ss, token, delim)) {
cont.push_back(token);
}
std::string tmp("");
for (auto & e : cont)
tmp = tmp + " " + e;
cont.erase(cont.begin(), cont.end());
tmp = trim(tmp);
std::stringstream s2(tmp);
while (std::getline(s2, token, delim2)) {
cont.push_back(token);
}
return cont;
}
std::string trim(std::string s1){
if (s1[0] == ' ') s1.replace(0, 1, "");
std::reverse(s1.begin(), s1.end());
if (s1[0] == ' ') s1.replace(0, 1, "");
std::reverse(s1.begin(), s1.end());
return s1;
}
Jeśli chodzi o split, to on rozdziela stringi na listę zgodnie z delimiterem.