I'm sure this is simple, but can someone please tell me why the following code prints the user prompt twice? Thanks in advance.
#include <stdio.h>
int main(void) {
char task = 't';
while (task != 'q') {
printf("What do you want to do? (quit with 'q'): ");
scanf("%c", &task);
}
}
Output:
What do you want to do? (quit with 'q'): a
What do you want to do? (quit with 'q'): What do you want to do? (quit with 'q'): b
What do you want to do? (quit with 'q'): What do you want to do? (quit with 'q'): c
What do you want to do? (quit with 'q'): What do you want to do? (quit with 'q'): q
It exits on 'q' like it should. Thanks for your help.