I'm new to programing and trying to learn C on my own. However I've encounetred a problem I don't know how to solve. This is my simple program. Sorry for grammar mistakes english is my second language.
int main(){
int x, confirmation;
do{
printf("\nTest Data: ");
scanf("\n%d ", &x);
printf("Do you want to stop? Y/N");
confirmation = getchar();
} while(confirmation != 'Y');
return 0;
}
This is in Codeblocks btw.
When executing the program 'Test Data:' and scanf are fine but then first it asks for getchar before executing the second printf. Besides that the program works fine, when I input 'Y' in ends as it should but not before executing the second printf.
Like This:

Before using getchar I used scanf("%c",...) but the problem was the same. I also tried while loop.
It's because it's stuck in the
scanfbecause of the space after%d. Remove that space and then read until you get to the newline. It could look like this: