A Small Good Habit of Equality Test

Many programmers make mistakes at times by writing “=” instead of “==” in equality test. A good habit of programming is to write the constant first. For example, if we want to test if the length of a string is equal to 0. Instead of writing

strlen(x) == 0

We can

write 0 == strlen(x)

In case we write “=” by mistake,

0 = strlen(x)

The compiler will complain about it.

In this way, we will easily find the bug at the compilation instead of squeezing head.