In C programming, a void pointer, also known as a generic pointer, is a pointer that can point to any type of data. It is declared using the void * data type.
A void pointer does not have a specific data type associated with it, and it cannot be dereferenced directly. Instead, it must be cast to a specific data type before it can be dereferenced and used to access the data it points to.
Here is an example of how a void pointer can be used in C:
This program demonstrates how to use a void pointer to access elements of an array. It also demonstrates how to use type casting to access the data stored at the memory location pointed to by the void pointer.
//Generic Pointer or Void Pointers #include<stdio.h> int main() { int a[]={10,20,30,40,50}; void *p; p=a; //printf("\n *p : %d",*p); printf("\n *p : %d",*(int *)p); return 0; }To download raw file Click Here
*p : 10
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions