+ 1
Are '\0' and NULL the same?
2 odpowiedzi
+ 4
no '\0' is a char and NULL is a void pointer
they can be compared as "nothing" and be equal because "nothing" is the same as "nothing." this detail is more obvious in assembly language (under the hood, all data is just numbers regardless of type so an empty void pointer is conventionally 0 and char '\0' is compiled as just the value 0, hence why they are "equal")
0
'\0' is a character constant used to terminate a string. It represent a null character
null is a macro for a pointer constant. It points to nothing
using them interchangeably may cause undefined behavior