Mega Code Archive

 
Categories / C / Code Snippets
 

Use for loop as the user selections controller

#include <stdio.h> #include <conio.h> int main(void) { int j; char ch; ch = 'a'; /* initial value */ for(j=0; ch != 'q'; j++) { printf("pass: %d\n", j); ch = getchar(); } return 0; }