Created
November 13, 2017 15:09
-
-
Save jmunozal/bfcf9e0dc809049ef37756388b9f3daf to your computer and use it in GitHub Desktop.
c++ split string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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