fork(1) download
  1. #include <iostream>
  2. #include <cctype>
  3.  
  4. int main()
  5. {
  6. char c;
  7. while ( std::cin.get( c ) && c != '|' )
  8. {
  9. if ( !std::isdigit( c ) )
  10. continue;
  11.  
  12. std::cin.putback( c );
  13.  
  14. int i, j;
  15. if ( std::cin >> i >> j )
  16. std::cout << i << ' ' << j << std::endl;
  17. else
  18. std::cin.clear();
  19. }
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 15240KB
stdin
this line will be ignored for it is not a stop character nor a pair of numbers
123 <- won't be printed: not a pair of numbers
456 789 <- will be printed
| this will break the loop
901 234 <- won't be printed: we left the loop
stdout
456 789