Quote:
|
Originally Posted by roknjohn
Code:
if (myvar=0)
{
dosomething();
}
|
If you get yourself in the habit of specifying the constant first then the variable, you'll produce a compiler error if you only have 1 = sign. Our coding standard at work specifies this as a requirement to catch at least some of these types of errors. The above code would then become:
Code:
if(0 = myvar)
{
dosomething();
}
which will give an error. Doesn't solve all the problems but it at least allows you to catch a few simple mistakes...