Comparison of zero values:
1. bool type and zero value
Bool btestval;
It is better to write if (btestval) And if (! Btestval)
Instead of writing it as: If (btestval = 0) and if (btestval! = 0) // easy to misunderstand
Do not write it as follows: If (btestval = true) And if (btestval = false) // Some compilers treat true as-1, such as Visual Basic
2. Comparison between float variables and zero values
Float ftextval = 0.0;
If (ftextval> = 0.0-epsinon) & (ftextval <= 0.0 + epsinon) epsinon is the determined precision.
3. Comparison between NULL pointer and zero value
Int * P = NULL;
If (null = P) and if (null! = P ),Develop the habit of writing null at the beginning and variables at the end, because if a = sign is missing, the compiler will report an error. If it is written as if (P = NULL), the compiler will not report an error, it is very troublesome to check the error.