Regarding the advantages of using braces with if instructions...
A common mistake is to forget that the compiler does not see indentation. These two snippets are different:
Even experienced programmers may fail to notice this error in a 500-line source file.
A common mistake is to forget that the compiler does not see indentation. These two snippets are different:
Code:
if (a > 10)
a += 100;
a *= 10;
printf("%d\n", a);
if (a > 10) {
a += 100;
a *= 10;
}
printf("%d\n", a);
Comment