1、字符串分割函数。比如把形如:“aa:bb:cc”这样的字符串去掉“:”分割成三部分放入str_vec中。(2016/4/19)
//字符串分割函数 std::vector<std::string> SplitString(std::string str_src, std::string symbol) { std::string str = str_src + symbol; //扩展字符串尾部以方便操作 std::vector<std::string> str_vec; while (std::string::npos != str.find(symbol)) { std::string::size_type pos = str.find(symbol); std::string str_sub = str.substr(0, pos); str_vec.push_back(str_sub); str = str.substr(pos + 1, str.size() - 1); } return str_vec; }