fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. istream& get_number( istream& is, int& n )
  6. {
  7. while ( is && !isdigit( static_cast<unsigned char>( is.get() ) ) )
  8. ;
  9. is.unget();
  10. return is >> n;
  11. }
  12.  
  13. int main()
  14. {
  15. int n;
  16. while ( get_number( cin, n ) )
  17. cout << n << ' ';
  18. }
Success #stdin #stdout 0s 4476KB
stdin
Hello 1234 World 9876 Hello1234
stdout
1234 9876 1234