I’m writing a demo program from an educational book made to teach “C” for Unix and Windows. However, sometimes I come across code that, when typed exactly, does not want to work.
Eg.
#include <stdio.h>
int main()
{
/*This next line is the error */
int num = 2, bool = 0;
if ( (num==2) && (!bool) )
{
printf("The first test is untrue\n");
}
else if( (num==2) && (!bool) )
{
printf("The second test is true\n");
}
else if( (num==2) && (bool==0) )
{
printf("The third test is true - but unreached\n");
}
return 0;
}
Anyway, like I mentioned in the title, I am curious if I have these variables declared properly. I am using a windows OS (7).
With a C compiler, there shouldn’t be an error because
boolis neither a type nor a reserved word in C.With a C++ compiler, however, you will probably get a parsing error.