while loop char input
Hey guys is there anything wrong with how im getting the input for a single character because for some reason the if statement is not working properly.
Even if i do enter the correct input it still prints as invalid?
printf("Enter guess type((f)lag, (u)ncover or(s)weep:\n");
valid = 0;
while((type = fgetc(stdin) != '\n' && type != EOF))
if(type != 's' || type !='u' || type != 'f')
Your if() statement should test as follows:
if(type != 's' && type !='u' && type != 'f')
>type = fgetc(stdin)
fgetc() doesn't return a char, it returns an int.