fork(4) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8. istringstream iss("1 a 1 b 4 a 4 b 9");
  9. cin.rdbuf(iss.rdbuf());
  10. int num = 0;
  11. char c;
  12. while(cin >> num >> c || !cin.eof()) {
  13. if(cin.fail()) {
  14. cin.clear();
  15. string dummy;
  16. cin >> dummy;
  17. continue;
  18. }
  19. cout << num << ", " << c << endl;
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
1, a
1, b
4, a
4, b