fork download
  1. #include <iostream>
  2. #include <string>
  3. int main() {
  4. while (true) {
  5. std::string input;
  6. int num = 0;
  7.  
  8. std::cout << "What number do you want to show?";
  9. std::cin >> input;
  10. try
  11. {
  12. num = std::stoi(input);
  13. if (num >= 0 && num < 10)
  14. {
  15. std::cout << "FILLER: This will draw the number";
  16.  
  17. exit(0);
  18. }
  19. else {
  20. std::cout << "FILLER: This is the else";
  21. exit(1);
  22. }
  23. }
  24. catch (std::runtime_error e)
  25. {
  26. std::cout << e.what();
  27. //std::cout << "That is not a valid number." << '\n';
  28. }
  29. }
  30. return 0;
  31. }
Runtime error #stdin #stdout #stderr 0s 4196KB
stdin
not a number
stdout
What number do you want to show?
stderr
terminate called after throwing an instance of 'std::invalid_argument'
  what():  stoi