Inspired by a program described in K&R section 5.5:
void strcpy(char *s, char *t){ while(*s++ = *t++);}
C program
if ('\0') { printf("\'\\0\' -> true \n"); }else { printf("\'\\0\' -> false\n"); }if ("\0") { printf("\"\\0\" -> true \n"); }else { printf("\"\\0\" -> false\n"); }
prints
'\0' -> false"\0" -> true
Why do '\0'
and "\0"
evaluate differently in C?
clang version 3.8.0