Void pointer in c
//Void pointer used to store value of other variables y z etc in one another variable x etc
#include <stdio.h>
int main()
{ void *v;
// int *p , *q;
int x =10 , y;
float avg = 12.12;
char k = 'A';
v = &x;
y = *((int *)v);
printf("y=%d\n" , y);
v=&k;
printf("y = %c\n" , *(char *)v);
v = &avg;
printf("y= %f\n", *((float *)v));
return 0;
}
Comments
Post a Comment