#include<stdio.h>
int main()
{
char arr[] = "hello";
printf("str = %s, %ld %ld\n",arr, sizeof(arr), sizeof(*arr) );
return 0;
}
以上程序返回:str = hello, 6 1
而
#include<stdio.h>
int main()
{
char *arr = "hello";
printf("str = %s, %ld %ld\n",arr, sizeof(arr), sizeof(*arr) );
return 0;
}
该程序返回str = hello, 8 1
为什么在这两种情况下sizeof(arr)的收益不同?