C + + String Segmentation method

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.