Okay, let's try something else.
I have this;
string input = "0 1,2,3";
I need to discard the first integer and plug the comma-separated ones (discaring commas of course) into a vector<int> - How can I do this?
Bonus points if you can tell me how to quickly regrow all the hair I've been pulling out.
Something along these lines:
1 2 3 4 5 6 7 8 9 10 11 12
|
for(int i = 0; i < input.size(); ++i)
{
if(input[i] == ',') input[i] = ' ';
}
std::stringstream ss(input);
int n;
ss >> n; // discard the first value
std::vector<int> v;
while(ss >> n)
{
v.push_back(n);
}
|
I can't help you with the hair loss, though.
Last edited on