C language: the use of sizeof, which is not a function, is an operator keyword, defines an array arr, the output arr and & arr difference
About the use of sizeof, note that it is not a function, it is an operator keyword program 1:
#include <stdio.h>void fun(int arr[10]){printf("fun::%d\n", sizeof(arr));//}int main(){int i = 10;short a = 0;int arr[10];fun(arr);printf("%d\n", sizeof(arr));//40 printf("%d\n", sizeof(a++));//2printf("%d\n", a);//0printf("%d\n", i);//10system("pause");return 0;}
Result: fun: 4402010 press any key to continue... program 2:
Defines an array of arr, and the difference between output arr and & arr # include <stdio. h> int main () {int n = 10; int arr [10] = {0}; int * p = NULL; int (* q) [10] = NULL; printf ("% d \ n", sizeof (n); // 4 printf ("% d \ n", sizeof (int )); // 4 printf ("% d \ n", sizeof (arr); // 40 printf ("% d \ n", sizeof (& arr )); // 4 printf ("% p \ n", arr); // 00D4FACC & arr [0], which indicates the address of the first element of the array printf ("% p \ n ", & arr); // 00D4FACC, which represents the address of the array. The two represent different meanings. p = arr; q = & arr; printf ("p + 1 = % p \ n", p + 1); // p + 1 = 007DF958printf ("q + 1 = % p \ n ", q + 1); // q + 1 = 007DF97Creturn 0 ;}
Result: 4440400F5F7C800F5F7C8p + 1 = 00F5F7CCq + 1 = 00F5F7F0 press any key to continue...