Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // example void pointer by Cooler_
- #include <stdio.h>
- void foo(void *point,int size)
- {
- // int == 4 bytes
- if(size==sizeof(int))
- printf("int : %d , bytes: %d\n",*(int *)point,sizeof(point));
- // double == 8 bytes
- if(size==sizeof(double))
- printf("double : %f , bytes: %d\n",*(double *)point,sizeof(double));
- }
- int main()
- {
- int a=64;
- double b=3.14;
- void *o=&b,*z=&a;
- printf("bytes of void : %d\n",sizeof(void));
- foo(z,sizeof(int));
- foo(o,sizeof(double));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment