1. SizeOf is a keyword, not a function, so don't look at it as a function.
The following are correct:
int Ten ; printf ("%d\n"sizeof i); printf ("%d\n"sizeof (int));
The following are the wrong:
printf ("%d\nint");
2. sizeof is executed at compile time, but it can also be executed during the execution period in the compiler implementing ISO C99.
So the following definition is correct:
Char array[sizeof(int);
3. In a 32-bit system, sizeof has any type of pointer, which is 4 because the length of the pointer is 4byte.
4. When the object of sizeof is an array name, the actual length of the array is returned.
Example:
CharA[] ="ABCDE"; intb[3]; Char(*C) [] = {"a","b","C" }; Char*d[] = {"AAA","BBB","CCC" }; printf ("%d\n",sizeofa);//Output 6 Because there is ' a 'printf"%d\n",sizeofb);//Output 3*4=12printf"%d\n",sizeofc);//output 8, which is an array pointer, it's essentially a pointer, so in 64bit, the sizeof pointer =8printf"%d\n",sizeofD);//Output 24, this is an array of pointers, its essence is an array, which holds 3 pointers, so =8*3=24printf"%d\n",sizeofAsizeof(Char));//output 6, which is how many elements in an array we have to find
5. When the array is passed as a parameter, the pointer is passed, and the sizeof object is actually a pointer:
void Fun (char a[]) { printf ("%d\n"sizeof// output 8}
6. Each of the basic types of sizeof,64-bit system :
printf"%d\n",sizeof(Char));//Output 1printf"%d\n",sizeof( Short));//Output 2printf"%d\n",sizeof(int));//Output 4printf"%d\n",sizeof(Long));//Output 8printf"%d\n",sizeof(float));//Output 4printf"%d\n",sizeof(Double));//Output 8printf"%d\n",sizeof(unsignedChar));//Output 1printf"%d\n",sizeof(unsigned Short));//Output 2printf"%d\n",sizeof(unsignedint));//Output 4printf"%d\n",sizeof(unsignedLong));//Output 8
[Linux] sizeof small note