Asking user if he/she wants to continue

Hi everyone, I need to ask user if he/she wants to continue, and if user types "Y"
then program continues, if user types "N" then program stops. How can I do it?
And what library to use if any needed? What functions to use? And how to implement it?
Last edited on
Sounds like a while loop to me.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char** argv){
char check[2];
char no[] = "n";
printf("Type n to quit\n");
scanf("%s",check);
if(!(strcmp(check,no))){
printf("Okay exiting\n");
exit(1);
}
//rest of program here
return 0;
}


This will exit if the user presses n and continue if they type anything else.
Topic archived. No new replies allowed.