以下是我如何使用字符串標記器。字符串標記器失敗
typedef std::string string_t;
typedef std::vector<string_t> stations_t;
void Tokenize(const string_t& str, stations_t& tokens,const string_t& delimiters = " ") {
string_t::size_type lastPos = str.find_first_not_of(delimiters, 0);
string_t::size_type pos = str.find_first_of(delimiters, lastPos);
while (string_t::npos != pos || string_t::npos != lastPos){
tokens.push_back(str.substr(lastPos, pos - lastPos));
lastPos = str.find_first_not_of(delimiters, pos);
pos = str.find_first_of(delimiters, lastPos);
}
}
當我傳遞字符串1,8003,1,HWH,Kolkata Howrah Junction,,16:10,,1,0
這一點,它返回我8
領域,在那裏,它應該返回9
,它是完全忽略,,
一部分。任何人都可以看看,並幫助我找到這裏的錯誤。