누구나 설명해 주시겠습니까? 내 'while'루프가 문자 'Q'를 입력하면 종료되지 않습니다. 사용자가 'Q'를 입력 할 때 부울 값을 false로 설정 했는데도이 값은 char input
에 해당하는 scanf 이후에 끝납니다.While 루프 while C
내 코드 :
#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;
}
Q를 입력 한 후 Enter 키를 누르셨습니까? – immibis
또 다른 scanf 문제가 있습니까? –
예 입력을 누르십시오. – Impalerz