#include <stdio.h>
#include <string.h>
int main()
{
char a[10] = "\0";
char *pa = (char *)&a;
char (*paa)[10] = &a;
printf("-----a[10]----\n");
printf("a size:%d, pa size;%d, *pa size:%d, *paa size:%d\n", sizeof(a), sizeof(pa), sizeof(*pa), sizeof(*paa));
return 0;
}
#./aaa
-----a[10]----
a size:10, pa size;8, *pa size:1, *paa size:10
当字符数组的首地址,强制转化成char *
指针后: sizeof(*ptr) 不为array的大小;
原文地址:https://www.cnblogs.com/muahao/p/9032915.html
时间: 2024-10-01 02:51:43