lundi 24 août 2020

"if" statement being ignored. (C)

So, I've been trying to use an if statement to create a procedure, although, for some reason, it keeps getting ignored when executed.

char s;
printf("Is that correct?(y/n)\nAnswer: ");
s = getchar();
putchar('\n');

if ( s == y ){
    printf("Your profile has been saved. Thank you.");
}
    else{
        printf("Please close thee tab and repeat the process.");
}
putchar('\n');
return 0;}

And then I get the following output:

"Is that correct?(y/n)

Answer:

Please close the tab and repeat the process.

Process returned 0 (0x0)"

Despite not giving getchar() any input it just keep getting skipped.

What should I do?

Aucun commentaire:

Enregistrer un commentaire