Skip to content

Instantly share code, notes, and snippets.

@jmunozal
Created November 13, 2017 15:09
Show Gist options
  • Save jmunozal/bfcf9e0dc809049ef37756388b9f3daf to your computer and use it in GitHub Desktop.
Save jmunozal/bfcf9e0dc809049ef37756388b9f3daf to your computer and use it in GitHub Desktop.
c++ split string
std::string s = "scott>=tiger>=mushroom";
std::string delimiter = ">=";
size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
std::cout << token << std::endl;
s.erase(0, pos + delimiter.length());
}
std::cout << s << std::endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment