I'm writing a program in C for an assignment and I'd like to work on it on my Windows 10 desktop, however I'm encountering a strange issue when using MinGW.
The program I have written is as seen below:
#include <stdio.h>
int main(){
//set up variables
int a, b, c, d;
//prompt user for integers
printf("Please enter four different integers:\n");
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
scanf("%d", &d);
//return sum
int sum = a+b+c+d;
printf("Sum is: %d", sum);
return 0;
}
When I compile this, the output looks like this: (Where 1, 2, 3 and 4 are the inputted numbers)
1
2
3
4
Please enter four different integers:
Sum is: 10
This obviously should not happen because that's out of order. To try and troubleshoot, I compiled this same code using GCC on my laptop running Arch and the output looked like this: (Where 1, 2, 3 and 4 are the inputted numbers)
Please enter four different integers:
1
2
3
4
Sum is: 10
This is what the output should look like. I am using Eclipse Mars as an IDE on both the Linux and the Windows computers. I also tried the same on my other laptop that dual boots Windows 10 and Ubuntu and had the same results between MinGW and GCC.
If anyone has any ideas why MinGW would be acting this way I'd greatly appreciate it! Thanks!