void*
is the type of a location in memory if you don't know what it contains. It should be avoided.
char*
is the type of a value which points to some location in memory which holds a char
. Identifying a location in memory takes eight bytes.
sizeof
tells you how many bytes a particular type takes. Not how many were allocated with malloc
but just how much memory compiler knows the type should take. Applying sizeof
to values is often considered bad style, and as someone else mentioned here, sometimes invokes smart behavior in C99.
char[100]
the type of a value which holds 100 chars. char[100] a;
is a string of 100 char
s on the stack.
char(*)[100]
is the type of a pointer to a value that holds 100 chars. char(*b)[100];
makes b
point to 100 chars, possibly on the heap. What you probably want is
char (*s)[100] = malloc( sizeof( char[100] ) );
printf( "%u byte pointer to %u bytes of size %u elements\n",
sizeof s, sizeof *s, sizeof **s );