Mega Code Archive

 
Categories / C / Code Snippets
 

Do while loop for your selection

#include <stdio.h> int main(void) { char ch; do { printf("Load, Save, Edit, Quit?\n"); do { printf("Enter your selection: "); ch = getchar(); } while(ch!='L' && ch!='S' && ch!='E' && ch!='Q'); if(ch == 'Q') { printf("Exit."); } } while(ch != 'Q'); return 0; }