First, looking at the two conditions, '\0'
is a constant of type integer, which denotes the null character C, which is the same as 0
. While "\0"
is a string literal, which contains 2 bytes, the one specified and the null terminator byte implicitly added. Being a string literal, the pointer cannot be NULL
.
Second, in C, for the condition of if
statement, everything non-zero is evaluated as true
, and zero is evaluated as false
.
According to this rule, it will be clear that '\0'
is false
, and "\0"
evaluated as true
.