1.指针
int main(){
char str2[10]="Hello";
printf("sizeof(str2): %d bytes\n", sizeof(str2));// 10 == array.length
printf("sizeof(&str2): %d bytes\n", sizeof(&str2));//sizeof(char*)
printf("%p\n", str2); // 0x7fff5fbff79e
printf("%p\n", str2 + 1); //0x7fff5fbff79f (== 0x7fff5fbff79e + 1)
printf("%p\n", (&str2));// 0x7fff5fbff79e
printf("%p\n", (&str2 + 1));0x7fff5fbff7a8 (== 0x7fff5fbff79e + 10 (== array.length))
printf("\n%p %c, %p %c\n",str2, *(str2), *(&str2), **(&str2));
// 0x7fff5fbff79e H, 0x7fff5fbff79e H
// str2 == *(&str2) , *(str2) == **(&str2)
return 0;
}
http://stackoverflow.com/questions/15177420/what-does-sizeofarray-return/15177499#15177499
其中答案还具体解释了Difference between char *str and char str[] and how both are stored in memory。