In addition, what sizeof returns depends on the platform and also glibc installed on the system (processor X86 or x86_64). Here is what I get when I run the following on a Linux system (Fedora Core 17 X86_64; ldd (GNU libc) 2.15)
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
int array[3] = {1,2,3};
printf("sizeof(array) = %lu\n", sizeof(array));
printf("sizeof(array[0]) = %lu\n", sizeof(array[0]));
printf("sizeof(int) = %lu\n", sizeof(int));
printf("sizeof(int *) = %lu\n", sizeof(int *));
printf("size_t = %lu\n", sizeof(size_t));
return 0;
}
Which returns the following (depending on your system/platform you may get different result)
Code:
$ gcc -Wall testscript.c -o testscript
$ ./testscript
sizeof(array) = 12
sizeof(array[0]) = 4
sizeof(int) = 4
sizeof(int *) = 8
size_t = 8
$
As far as I remember according to C99, size_of is at least 16 bits (therefore 8 is returned by sizeof)
Regards,
Dariyoosh