5.1.2.2 Sizeof Operator With Pointer Types
The C sizeof operator when acting on pointer types
or on structure or array types that contain a pointer may not work reliably. This
operator, however, may be used with pointer, structure, or array identifiers. This
is due to the dynamic nature of pointer size used by the compiler.
For the following code:
char * cp;
size_t size;
size = sizeof(char *);
size = sizeof(cp);
size in the first example will be assigned the maximum
size a pointer can be for the particular target device you have chosen. In the second
example, size will be assigned the actual size of the pointer variable,
cp.
The sizeof operator using a pointer variable operand cannot be used as the
number-of-elements expression in an array declaration. For example, the size of the
following array is unpredictable:
unsigned buffer[sizeof(cp) * 10];
