> b) NULL is not a useful macro. For example,
> printf ("%p", NULL);
> can have unexpected results.
How do you figure?
How do you figure?
#define NULL ((void *) 0)
or just plain #define NULL 0
The latter works correctly because a literal 0 in pointer context is interpreted by the compiler as a null pointer.If it is 0, the printf() provides no pointer context, so the 0 is interpreted as an int. That works... poorly if sizeof (int) < sizeof (void *)
Is there any reason for an implementation to elect to use the non-casted version of NULL? It seems like an oversight.