Better coding style for comparisonThis tip submitted by nids on 2006-01-31 07:57:07. It has been viewed 26298 times.
Rating of 5.9 with 424 votes
Always try to compare like
if ( 0 == i )
if ( i == 0)
In this way you can catch error for unintended assignments like
if ( 0 = i)
Help your fellow programmers! Add a tip!
Want to become a C++ programmer? The Cprogramming.com ebook, Jumping into C++, will walk you through it, step-by-step. Get Jumping into C++ today!