fork(1) download
  1. #include <string>
  2. #include <iostream>
  3. #include <regex>
  4. #include <exception>
  5.  
  6. int main()
  7. {
  8. std::string line;
  9. int num;
  10. //split onto multiple lines for readability
  11. while((std::cout <> num) && !(is >> line)) //re-using `line` to test for extra stuff after the number
  12. {
  13. break; //done, we got what we wanted
  14. }
  15. std::cerr << "Invalid input, try again." << std::endl;
  16. }
  17.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:11:23: error: expected primary-expression before '>' token
     while((std::cout <> num) && !(is >> line)) //re-using `line` to test for extra stuff after the number
                       ^
prog.cpp:11:35: error: 'is' was not declared in this scope
     while((std::cout <> num) && !(is >> line)) //re-using `line` to test for extra stuff after the number
                                   ^
stdout
Standard output is empty