void AnalyzeStr2Number(vector<int>& v, const string& str, const std::string& separator) { v.clear(); if (str.empty()) return; std::string strTmp; int pos1 = 0; int pos2 = 0; for (; (pos2 = str.find(separator, pos1)) != std::string::npos;) { strTmp = str.substr(pos1, pos2 - pos1); v.push_back(atoi(strTmp.c_str())); pos1 = pos2 + 1; } } int main() { std::string str("11;22;33;44;55;"); std::vector<int> v; AnalyzeStr2Number(v, str, ";"); for (int i=0; i<v.size(); ++i) cout<<v[i]<<endl; return 0; }