void指针
void指针平时用的地方不多,但是不代表它不重要
#include <stdio.h>
typedef int*(*TY)[5]; //指针数组的指针类型
int main(void)
{
void *p1,*p2,*p3;
int a1 = 100;
int *px = &a1; //一级指针
int **py = &px; //二级指针
int a[5] = {1,2,3,4,5};
int *b[5] = {a,a+1,a+2,a+3,a+4}; //指针数组
p1 = &py;
p2 = b;
p3 = &b;
printf("***(int***)p1 = %d \n",***(int***)p1);
printf("**((int**)p2 + 1)) = %d \n",**((int**)p2 + 1));
printf("(((int**)p2)[1][0]) = %d \n",((int**)p2)[1][0]);
printf("(*(TY)p3)[1][0] = %d \n",(*(TY)p3)[1][0]);
printf("**(*(TY)p3 +1) = %d \n",**(*(TY)p3 +1));
return 0;
}
代码测试结果
QQ联系方式:[email protected]
出处:lcw.cnblogs.com
本文申明:本文版权归作者和博客园共有,欢迎转载,转载请注明出处.