-1
if 및 else 문이있는 코드에 문제가있어서 정수를 입력해야하며 그렇지 않으면 다시 입력하라는 메시지가 표시됩니다. 코드는 while 문에 있고 문제는 내가 정수보다 무엇을 입력 할 때 루프가 다른 문을 제공 걸리면이다 또한 코드는 while 문C - if-else 문이 멈추고 충돌이 발생합니다.
while (1) {
blink_leds();
number_console();
}
에 사용되는
static inline void number_console(void)
{
int x = 0;
fprintf_P(stdout, PSTR(GET_NR_MSG));
lcd_goto(0x40);
if (scanf("%d", &x) == 1 && x >= 0 && x <= 9) {
printf("\nYou entered number: ");
fprintf_P(stdout, (PGM_P)pgm_read_word(&numbers[x]));
fputc('\n', stdout);
lcd_puts_P((PGM_P)pgm_read_word(&numbers[x]));
lcd_putc(' ');
} else {
printf("invalid input\n");
}
}
충돌
입니다. 또는 사용자가 enter 키를 누르면 getchar()을 입력 한 다음 scanf()를 입력하십시오. – Lundin