The results of the sizeof array and pointers are different
- When ARR is an array, the result of sizeof (ARR) is the number of bytes that the elements in the entire array occupy
- And when P is a pointer, even pointing to an array, the result of sizeof (p) must be 4 in the System 32.
The verification code is as follows:
/* The result of the sizeof array and the pointer is different when ARR is an array, the result of sizeof (ARR) is the number of bytes in the entire array and when P is a pointer, the result of sizeof (p) must be 4 per 32 for the system, even if it points to an array #include <stdio.h>intGetSize (intArr[]) {return sizeof(arr);}intMainvoid){intarr[]={1,2,3,4};intsize1=sizeof(arr);int*p1=arr;intSize2=sizeof(p1);intSize3=getsize (p1);printf(" %d%d%d", size1,size2,size3);return 0;}
The result of the program is: 16 4 4
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The result of sizeof (array name) and sizeof (pointer name) is different