fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5. int main(void) {
  6. int n = 0;
  7. while (true) {
  8. printf("this is loop number %d\n", n++);
  9. printf("do you wish to continue? (y/n)\n");
  10. char c;
  11. if (scanf("%c\n", &c) != 1 || c != 'y') { // or scanf(" %c", &c)
  12. break;
  13. }
  14. }
  15. }
Success #stdin #stdout 0s 2172KB
stdin









wrong input
stdout
this is loop number 0
do you wish to continue? (y/n)