Usually do projects are in the Java language, when the graduation thesis, need to use OpenGL, and the relationship between OpenGL and C + + is very close and reference is also rich, in the process of program development to the string segmentation, check API unexpectedly did not find its own split function, Here's a note on the C + + string segmentation method.
static void split (const string& SRC, const string& separator, vector<string>& dest) {string str = Src;str ing substring;string::size_type start = 0, Index;do{index = str.find_first_of (Separator,start); if (Index! = String::npos { substring = str.substr (start,index-start);d est.push_back (substring); start = str.find_first_not_of (separator , index); if (start = = String::npos) return;}} while (Index! = string::npos);//the last tokensubstring = Str.substr (start);d est.push_back (substring);}
C + + String Segmentation method