What is a Void Pointer?
Void pointer is a pointer which has no associated data type with it.
It can point to any data of any data type and can be typecasted to any type.
Example:
int main(){
int n = 10;
void *ptr = ∧
printf("%d", *(int*)ptr);
return 0;
}
Output:
10
Used of Void Pointer
malloc and calloc function returns a void pointer. Due to this reason, they can allocate a memory for any type of data.
Syntax:
void* malloc(size_t size);
malloc and calloc are used to allocate memory at runtime.
