My input format :
192,21,4 33,2,1 23,7,61
and I want to obtain only numbers.
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
int strtoint(const std::string str){      //converting the string to integer
    float a = str.length();
    int result = 0;
    for(int i=1; i<=str.length(); i++){
            result+=(str[i-1]-'0')*pow(10,(a-1));
            a--;
    }
    return result;
}
int main ()
{
  string name;
  string segment;
  while(getline (cin,name, ' ')){
        stringstream test(name);
        while(getline(test, segment, ','))
            {
              cout << segment <<" "<<strtoint(segment)<<endl;
            }
  }
  return 0;
}
I didn't obtain last one (61). So output is 192 21 4 33 2 1 23 7.
How do I get all the numbers?
 
     
     
     
    