vendredi 23 octobre 2015

nested if statment in a while loop C

So I have the following code and wondering why it won't be executed

int main() {
char select;
printf("Select q to quit\n");
while ((select = getchar()) != 'q') {
    if(select == 'a') {
        printf("You have not selected q\n");
        printf("Select q to quit\n");
    }
return 0;
}

So when select say 'a' for the character select, it doesn't go into the if statement. Why is that??

Aucun commentaire:

Enregistrer un commentaire