# Is something wrong with my compiler?



## sk8harddiefast (Jan 2, 2011)

I try to create in C the sipliest program ever! Make the sum of two numbers and print the result!
My code


```
#include <stdio.h>
int main (void)
{
	int a,b,c;
	
	scanf ("%d", &a);
	scanf ("%d", &b);
	c=a+b;
        printf ("%d\n",c);

return 0;
}
```

Is something wrong with my code? Compile fine but the executable return wrong results!
Also Compiling it with gcc45 return the right results! I start scratch me head.


----------



## adamk (Jan 2, 2011)

What compiler did you use when it produced the wrong results?  And what numbers did you test with and what result did you get?

Adam


----------



## mk (Jan 2, 2011)

The example works for me with gcc45. Try `$ /usr/local/bin/gcc45 my.c -o iNum`, this will compile your code in my.c into executable iNum. Easy distinguished from a.out and you are sure you execute a.out from myProg.c not from otherRandomProg.c ?


----------



## wblock@ (Jan 2, 2011)

Works here, too.  Maybe a confusion between stdin and arguments?


----------



## sk8harddiefast (Jan 2, 2011)

Now working on me too with gcc but I don't know why. 2 day now, was returning me results like 5.70000, 4.90000 etc. I am 1500 % sure for that. Even setting *int* and everything *%d* After compiled with gcc45 and try to compile it again with gcc (default) just worked and returned me right result. Also on IRC , one guy was telling me that the code was right but the results on me were wrong. Well now is working. Just I am curious if is any confusion. Why to do that? I don't know. Compiler seems to works fine and I have never any compilation problem, compiling ports.


----------

