+ 1

Are '\0' and NULL the same?

5th Jul 2025, 3:58 PM
Md Mehedi Hasan
Md Mehedi Hasan - avatar
2 Respuestas
+ 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")
5th Jul 2025, 4:46 PM
「HAPPY TO HELP」
「HAPPY TO HELP」 - avatar
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
6th Jul 2025, 7:21 AM
RuntimeTerror
RuntimeTerror - avatar