The void Data Type


The void data type is used to indicate the absence of a type. For example, a function that does not return a value may be defined as follows.

void f(void); // Has no parameters, returns no value
void g();     // Same as f except that () used instead of (void)

A variable of type void cannot be declared. The type void* may be used to declare a pointer to an unspecified type. Following are examples of using void*.

void* pointer;  // Declares a pointer to 'something'
void* f(void*); // A function accepting a pointer and returning a pointer

Any expression can be explicitly converted to the type void. The resultant expression may only occur: