I'm using Eclipse IDE I have the following simple code in C language:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int a;
printf("Enter a number");
scanf("%d",&a);
printf("You have entered %d",a);
return EXIT_SUCCESS;
}
So as you can see, there are two printf's. but if i run the code on console My scanf is running before my first printf displays. And all output printed together after the execution of scanf.
Then the result will be like this (This is what I'm getting in my console):
6
Enter a numberYou have entered 6
What i really wanted is:
Enter a number
6
You have entered 6
I tried adding fflush(stdout)
but the broblem still exists.
is there any working solution to fix this?