fork download
  1. #include <stdio.h>
  2.  
  3. int cont()
  4. {
  5. char c; do {
  6. printf("Continue (y/n): ");
  7. scanf("%c", &c);
  8. printf("Input '%c'\n", c);
  9. } while (c != 'y' && c != 'n');
  10. return c == 'y';
  11. }
  12.  
  13. int main()
  14. {
  15. int i = 0;
  16. do {
  17. printf("Loop iteration %d.\n", ++i);
  18. } while (cont());
  19. /* done */
  20. return 0;
  21. }
Success #stdin #stdout 0s 9424KB
stdin
y
n
stdout
Loop iteration 1.
Continue (y/n): Input 'y'
Loop iteration 2.
Continue (y/n): Input '
'
Continue (y/n): Input 'n'