fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int ask_to_exit()
  5. {
  6. int choice;
  7.  
  8. do
  9. {
  10. printf("Do you want to continue?(y/n):");
  11. choice = fgetc(stdin);
  12.  
  13. while (fgetc(stdin) != '\n');
  14.  
  15. if (choice == 'y') {
  16. return 0;
  17. } else if (choice == 'n') {
  18. return 1;
  19. } else {
  20. printf("Invalid choice!\n");
  21. }
  22. } while (1);
  23. }
  24. int main()
  25. {
  26. int exit = 0;
  27. while(!exit)
  28. {
  29. exit = ask_to_exit();
  30. }
  31. puts("Exiting...");
  32. return 0;
  33. }
  34.  
Time limit exceeded #stdin #stdout 5s 4428KB
stdin
d
d
g
s
y
n
stdout
Standard output is empty