Garmaine Staff asked 2 years ago

I want to read string and extract all numbers.

Input: 5a3 1f a0aaaa f1fg3

Output: 53 1 0 13

I tried this code:

string s;
getline(cin, s);
stringstream str_strm(s);

int found;
string temp;

while (!str_strm.eof()) {
    str_strm >> temp;
    if (stringstream(temp) >> found)
        cout << found << endl;

but when found 5 (from example)after that automatically start to check the other string. How can I extract all numbers?