B
BSDBlack
Hello,
I wrote this little program:
#include <stdio.h>
int main(void) {
int i, f[2];
for(i = 0; i<= 2; i++) {
scanf("%d", &f);
fflush(stdin);
}
if(f[0] == f[1] || f[1] == f[2] || f[0] == f[1] || (f[1] == f[2]
&&
f[1] == f[0])) printf("Same Numbers;\n");
else if(f[1] < f[0] && f[2] < f[0])
printf("%d\n", f[0]);
else if(f[0] < f[1] && f[2] < f[1])
printf("%d\n", f[1]);
else if(f[0] < f[2] && f[1] < f[2])
printf("%d\n", f[2]);
return 0;
}
when I run this program under Windows and input 4, 5, 6 it returns 7;
when I run this program under FreeBSD and input 4, 5, 6 it returns 6;
This happens only when the biggest number is the last input.
Why and when does Windows increment the last variable?
I'm using 64bit Windows XP with minGW and FreeBSD 8.2
amd64 with gcc 4.2.1
Sebastian
I wrote this little program:
#include <stdio.h>
int main(void) {
int i, f[2];
for(i = 0; i<= 2; i++) {
scanf("%d", &f);
fflush(stdin);
}
if(f[0] == f[1] || f[1] == f[2] || f[0] == f[1] || (f[1] == f[2]
&&
f[1] == f[0])) printf("Same Numbers;\n");
else if(f[1] < f[0] && f[2] < f[0])
printf("%d\n", f[0]);
else if(f[0] < f[1] && f[2] < f[1])
printf("%d\n", f[1]);
else if(f[0] < f[2] && f[1] < f[2])
printf("%d\n", f[2]);
return 0;
}
when I run this program under Windows and input 4, 5, 6 it returns 7;
when I run this program under FreeBSD and input 4, 5, 6 it returns 6;
This happens only when the biggest number is the last input.
Why and when does Windows increment the last variable?
I'm using 64bit Windows XP with minGW and FreeBSD 8.2
amd64 with gcc 4.2.1
Sebastian