Possible Duplicate:
Parsing a comma-delimited std::string
I want to parse a string into an integer vector:
string s = "1;2;4;8;16;";
vector<int> n = parse_string(s);
// n == [1, 2, 4, 8, 16];
Of course, I can write a simple code with strtok
and atoi
. But, what would be a much shorter code with C++ boost? I never tried with Boost, but heard that it could simply your code pretty much as if using Python.