Mega Code Archive

 
Categories / C / Code Snippets
 

Exit program without closing files

//Declaration: void _Exit(int exit_code); #include <stdlib.h> #include <stdio.h> int main(void) { char mychoice; do { printf("Quit (Q)\n"); mychoice = getchar(); } while(!strchr("Q", toupper(mychoice))); if(mychoice=='Q'){ _Exit(0); } return mychoice; }