Here is a beginner programme of finding weather an integer is even or odd. However I recieve a an error on the IF statment (highlighted in bold). Can someone please show me what is the error.
The Error reads: fatal error LNK1169: one or more multiply defined symbols found
Code:
#include
<stdio.h>void main()
{
int a;
printf("enter the number");
scanf("%d",&a);
if ((a%2)==0) //this line contains the error.
{
printf("Number is even");
}
else
{
printf(
"Number is odd");}
}

'IF' statement problem
dnweb
I copied and compiled your code in an empty win32 console app using VS2005. It does compile and works.
Your error is caused by something else. There is nothing wrong with your IF statement.
I would guess you have another source code file which you are linking in as well.
Billy Hildebrand
Do you only get the LNK1169 error Is there no LNK2005 error If there is no LNK2005 error then there is a problem with the compiler. If there is a LNK2005 error then it would have helped you to have shown it too in your question.
When you get an error such as this that you don't understand, the first thing to do is to look up the error code (LNK1169) in the documentation. In this situation, the description just refers us to LNK2005, which is the meaningful message and is the important one to show in your question. That description has useful information, so take a look at that.
NeroToxic
Would you care to explain what makes you believe that the error message is related the source line
The toolchain consists of more than just one tool. In your case the compiler will take your source file and create an object file from it. This has already generated code in it, but still has symbolic references to external sources. The linker will then take one or more object files, resolve references and generates the final image.
Since you get a linker error it means that the source file is syntactically correct (unless you have some odd build engine). Linker errors are not directly tied to a particular source line (the linker operates on object files not source files). Also you should typically see additional output before the error message, that tells you exactly which symbol is defined more than once and where it is.
In the IDE, it is generally a good idea to take a look at the output window instead of the errors window to get the full diagnostics. It should give you a much better idea to resolve your problems. Also it is usually a good idea to take a close look at linker warnings. Granted, there are some pretty harmless ones such as /OPT:REF removing DLL dependencies. But then, specifically mismatching runtime libraries will very often cause you trouble.
-hg