Could anyone please explain to me why my while loop won't end when i enter character 'Q'? It kept on looping even though i set my boolean value to false when the user enter 'Q', it supposed to end after that scanf for char input.
My code:
#include <stdio.h> typedef int bool; #define true 1 #define false 0 int main(void) { char input; char output; bool tf = true; printf("Welcome to the Coder!\n"); while (tf) { printf("Choose Input (H,A,B,Q) : "); scanf_s(" %c\n", &input); if (input == 'Q') { tf = false; } else { printf("Choose Output (H,A,B) : "); scanf_s(" %c\n", &output); } } return 0; }