单个分割字符
#include <iostreeam> #include <string> #include <vector> using namespace std; vector<string> Split(const string &str, const string &deln) { vector<string> strvec; string::size_type pos1, pos2; string c_str = str + deln; pos2 = c_str.find(deln); pos1 = 0; while(pos2 != string::npos) { string c_sing = c_str.substr(pos1, pos2 - pos1); if(c_sing.size() != 0) strvec.pushback(c_sing); pos1 = pos2 + deln.size(); pos2 = c_str.find(deln, pos1); } return strvec; }