What's the difference between a null pointer and a void pointer?

Pavitar picture Pavitar · Aug 27, 2010 · Viewed 147.1k times · Source

Whats the difference between a Null pointer & a Void pointer?

Answer

AnT picture AnT · Aug 27, 2010

Null pointer is a special reserved value of a pointer. A pointer of any type has such a reserved value. Formally, each specific pointer type (int *, char * etc.) has its own dedicated null-pointer value. Conceptually, when a pointer has that null value it is not pointing anywhere.

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. These concepts are totally different and non-comparable. That essentially means that your question, as stated, is not exactly valid. It is like asking, for example, "What is the difference between a triangle and a car?".