c. Enumeration and void Data Type

What is void data type in C

The void data type is an empty data type that refers to an object that does not have a value of any type. Here are the common uses of void data type. When it is used as a function return type.

void myFunction(int i);

Void return type specifies that the function does not return a value.

When it is used as a function’s parameter list:

int myFunction(void);

Void parameter specifies that the function takes no parameters.

When it is used in the declaration of a pointer variable:

void *ptr;

It specifies that the pointer is “universal” and it can point to anything. When we want to access data pointed by a void pointer, first we have to type cast it.

Leave a Reply

Your email address will not be published. Required fields are marked *