‘\0’ evaluates false, “\0” evaluates true

Recall how string literals work in C – "\0" is a character array containing two zero bytes (the one you asked for, and the implicit one at the end). When evaluated for the if test, it decays into a pointer to its first character. This pointer is not NULL, so it’s considered true when used as a condition.

'\0' is the number zero, equivalent to just 0. It’s an integer which is zero, so it’s considered false when used as a condition.

Leave a Comment