int x; while(input_stream >> x) my_vector.push_back(x); 

If a character that is not a number ( , or ; ) is encountered in the input stream input_stream , reading will stop. How can I continue reading integers after this? Am I doing the right thing?

 for (int i = 0; i < blocks_number; ++i) { while (input_stream >> x) my_vector.push_back(x); input_stream.clear(); input_stream.sync(); input_stream.ignore(); } 
  • one
    Maybe you can use the getch () and unget () functions that get char from the buffer / return, then check if the number is (for example, using is_number), then return the character to the buffer and read the number, otherwise just skip to the next iteration. - Jenssen

0