void 可以是指向任何类型的指针
如果要取值的话需要强转为对应类型指针
#include <stdio.h>int main(){int num = 1024;void *pv;// 指向 intpv = #// 强转为 int 指针 并取值printf("%d \n", *(int *)pv);return 0;}
野指针和 NULL
如果一个指针暂时未被指向任何数据就先定义一个 NULL 指针 一般指向地址 0
#include <stdio.h>int main(){int *p;int *p2 = NULL;// 野指针printf("%d \n",*p);// NULL 指针printf("%d \n",*p2);return 0;}
