No, you don't have issues with your compiler. Or, more exactly, this is very unlikely. g++ is a decent compiler, but it's for C++, not C; for C, you run gcc. Please see:
http://en.wikipedia.org/wiki/GNU_Compiler_Collection[
^].
Chances are, your problem is not a compiler, but your code, and, very likely, your understanding of what you are doing.
GNU, Microsoft, Intel compilers should be good enough for you. And you did not ask about IDE, only mentioned Dev+ (Dev-C++?), but this is not all. This is a whole different story.
[EDIT]
About your code:
This is the syntax error:
scanf(" %d". &year1);
Should be:
scanf(" %d", &year1);
Besides, declaration
int year1, year2;
outside the function is quite pointless.
—SA