ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Don't get screwed by C

<< < (2/2)

SkyIDE:
regarding the "if" statements

I have "unintentionally" done something like this:


--- ---if (something < some_thing else);
             ShowMessage ("Test");           

pay attention to the terminating char at the end of the "if" statement

Of course, the program didn't work as expected until you realise you have put ";" at the end of the "if" statement.

Basically, the code/statement between the closing brace ")" of the if statement and the ";" char gets executed but in this case, it is an empty statement ";" and nothing gets executed and a normal program flow continues to the next statement "ShowMessage("Test");

mouser:
yes that's the other really classic c error.

Navigation

[0] Message Index

[*] Previous page

Go to full version