#include <stdio.h> int main(void){ void *p; int a = 14322; char c ='A'; p = &a; //p = &c; //强制类型转换(int*)p 把变量指针p强制转换成指向int类型的指针 printf("a=%d ",*(int*)p); p = &c; printf("c=%c ",*(int*)p); return 0; }
#include <stdio.h> int main(void){ void *p; int a = 14322; char c ='A'; p = &a; //p = &c; //强制类型转换(int*)p 把变量指针p强制转换成指向int类型的指针 printf("a=%d ",*(int*)p); p = &c; printf("c=%c ",*(int*)p); return 0; }