fork(3) download
  1. #include <iostream>
  2. #include <limits>
  3.  
  4. void language();
  5.  
  6. int main() {
  7. language();
  8. }
  9.  
  10. void language() {
  11. int choice;
  12.  
  13. // Ask user for something and input
  14. std::cout << "Press 1 to exit the program\n\n";
  15. std::cin >> choice;
  16.  
  17. std::cin.clear();
  18. std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  19.  
  20. // Getting user's input and run the code below and find for specific words
  21. switch(choice) {
  22. case 1:
  23. std::cout << "\n\nEnding program...";
  24. break;
  25.  
  26. default:
  27. std::cout << "\n\nPlease type the specific number.\n\n";
  28. language();
  29. break;
  30. }
  31. }
Success #stdin #stdout 0s 3344KB
stdin
a
1
stdout
Press 1 to exit the program



Please type the specific number.

Press 1 to exit the program



Ending program...