Home / Programs / Write a example of void pointer.
Programming Example

Write a example of void pointer.

👁 1,283 Views
💻 Practical Program
📘 Step by Step Learning
Write a example of void pointer.

Program Code

#include <stdio.h>
int main()
{
	int a=5;
	double b=3.1415;
	void *vp;
	vp=&a;
	printf("\n a= %d", *((int *)vp));
	vp=&b;
	printf("\n a= %d", *((double *)vp));
	return 0;
} 

Output


 a= 5
 a= -1065151889

Explanation

None

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.