Last active
March 12, 2016 23:15
-
-
Save DavidLudwig/0d2759b4e5494625271e to your computer and use it in GitHub Desktop.
This file contains 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
#include <boost/utility/string_ref.hpp> | |
#include <stdio.h> | |
void process(boost::string_ref part) { | |
printf("process(\"%s\")\n", part.to_string().c_str()); | |
} | |
void split(boost::string_ref s, const char delim) { | |
size_t p; | |
while (true) { | |
p = s.find_first_of(delim); | |
process(s.substr(0,p)); | |
if (p == boost::string_ref::npos) { | |
break; | |
} | |
s.remove_prefix(p + 1); | |
} | |
} | |
int main(int argc, char ** argv) { | |
for (int i = 1; i < argc; ++i) { | |
split(argv[i], ';'); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment