Two things to be aware of in the C language that WILL bite you (ask me how I know :o ) - statements are terminated with a semicolon. The way you normally write a conditional statement is along the lines of
"if (this == that) { do some things}". the statements between the curly braces get executed. The common mistake is to put a semicolon after the "if (this == that) ;" which terminates the statement and the stuff following in the curly braces gets executed each time through because they are no longer part of the "if" conditional. The other common mistake is also in the conditional where you write "if (x = 5)" for example. What you are trying to do is test for 5, but what it really does is set x=5 which is then true. The double "==" tests the value while the single "=" assigns the value. (and both are "correct" statements and will compile without error!).