When terminating a string, it seems to me that logically char c=0
is equivalent to char c='\0'
, since the "null" (ASCII 0) byte is 0
, but usually people tend to do '\0'
instead. Is this purely out of preference or should it be a better "practice"?
What is the preferred choice?
EDIT: K&R says: "The character constant '\0'
represents the character with value zero, the null character. '\0'
is often written instead of 0
to emphasize the character nature of some expression, but the numeric value is just 0
.