Friday, August 5, 2011

void vs Null

Void should not be confused with null.

Null pointer is a special reserved value of a pointer. A pointer of any type has such a reserved value.

Void pointer is a specific pointer type - void * - a pointer that points to some data location in storage, which doesn't have any specific type.



So, once again, null pointer is a value, while void pointer is a type.
 
They are two different concepts: "void pointer" is a type (void *).
"null pointer" is a pointer that has a value of zero (NULL).

Example:
void *pointer = NULL; 

That's a NULL void pointer.

No comments:

Post a Comment