adplus-dvertising
Void Pointers In C Language
We can declare a pointer to be of any data type void, and can assign a void pointer to any other type.
Pointers

It gives error because the pointer p is of type void and cannot hold any value.

So, we have to type cast the pointer variable from one type to other type.

Pointers

The statement (int *) p makes p to become an integer type.

  Program : The following program is an example of void pointer.
#include < stdio.h>
 #include < conio.h>
 main()
 {
  int x = 27;
  void *p;
  p= &x;
  printf (“value is = %d”, * ((int *)p));
 }
Output :

Value is 27