Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

c continue loop

Name: Anonymous 2007-10-24 15:33

"Prompt user to enter 'c' to continue or 'q' to quit"

How do I add that code into my program, thanks alot!
I figure it has to be a typa loop?! i was thinking a while loop but when i tried that it did not work.

Name: Anonymous 2007-10-25 15:35

#include <stdio.h>

int main (void) {
   int c;
   printf("Press 'c' to continue or 'q' to quit.");
gotos_are_the_shit:
   c = getchar();
   if (c == 'q') return 0;
   if (c != 'c') printf("Idiot.");
   goto gotos_are_the_shit;
}

int main (void) {
   int c;
   do {
      printf("Press 'c' to continue or 'q' to quit.");
   } while ((c = getchar()) != 'q')
   return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List