I am doing a simple C program that accepts input and display some number.
#include<stdio.h>
#include<conio.h>
int main()
{
// setvbuf(stdout, NULL, _IONBF, 0);
int a, b, c;
printf("Enter two values: \n");
scanf("%d %d", &a, &b);
c = a + b;
printf("Total answer is %d", c);
return 0;
}
I am using gcc as compiler.
So the process is there is a text that asks for input, then input two numbers and display the result.
Now, if I compile and run my code in windows cmd, It works perfectly. No problem at all.
But, if I compile and run using git bash, it asks first for numbers before displaying the prompt that asks for number. It is like it runs the scanf() first before the first printf() function.
Do you know why? I am just curious why it gives different result.