Monday, July 27, 2009

C++ error message?

I keep getting an error in my program,


syntax error before '=' token





the line that it is referring to is,


if (number = =0) printf ("The bianary code for 0 is 00\n");





the whole program is here,


#include %26lt;stdio.h%26gt;


#include "genlib.h"


#include "simpio.h"





main()


{


int number;


number=GetInteger();


if (number = =0) printf ("The bianary code for 0 is 00\n");


else if (number = = 1) printf ("The bianary code for 1 is 01\n");


else if (number = = 2) printf ("The bianary code for 2 is 10\n");


else if (number = = 3) printf ("The bianary code for 3 is 11\n");


else if (number %26gt;3) printf ("The input you entered, %d, is out of range\n"number);


getchar();





}

C++ error message?
Do you have "= =" or "==" in those statements?





C++ (as well as C) expects to see "==" for an equality test
Reply:Try using a single = instead of a double = this might help- Good luck!
Reply:Well, I don't know what GetInteger() does...but whatever it returns the first if might not like.


Comment out your if and Print out the value of number first.


See what it is and if that GetInt function is working right
Reply:Your equality operators are wrong, its "==" instead of "= =" (no spaces. ignore the quotation marks in my example.


No comments:

Post a Comment