[Solved] find numbers at string line c++

As mentioned in @Jhonny Mopp’s comment the primary problem is, that you don’t read a whole line here:


it just reads up to the next whitespace delimiter.

What you actually want is:

getline(cin, line);

This would read in the whole input until you hit Enter.

Regarding the rest of processing refer to that Q&A I formerly marked as duplicate:

How to test whether stringstream operator>> has parsed a bad type and skip it


solved find numbers at string line c++