I do not know the answer to this, but I think. In C, you usually do a lot of mallocs and therefore a lot of tests for returned pointers. Since malloc returns void *, and especially (void *) 0 after a failure, NULL is a natural thing to determine in order to verify the success of malloc. Since this is so important, other library functions also use NULL (or (void *) 0), such as fopen. In fact, everything the pointer returns.
Therefore, there is no reason to define this at the language level - it is simply a special pointer value that can be returned by so many functions.
source
share