//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; }
//*P and **q denote a new one memory location.... #include <stdio.h> int main() { int i =10; int *p,**q; p = & i; q = & p; printf ("real value of i is %d\n",i ); printf("memory address of i is %u\n",&i); printf(" memory address of i stored in p is %u\n",p ); printf("memory address of p is %u\n",&p); printf("memory address of p stored in q is %u\n", q); printf("memory address of k is %u\n",&q); printf("\n\n"); printf("%d\n", *p); printf("%u\n", *q); printf("%u\n", **q); return 0; }
Comments
Post a Comment