标签:ret 不为 字符数组 字符 printf turn code ring pre
#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的大小;
C: 当字符数组首指针转化成char *指针,sizeof(*ptr)不为array的size
标签:ret 不为 字符数组 字符 printf turn code ring pre
原文地址:https://www.cnblogs.com/muahao/p/9032915.html