Hello everyone. I'm trying to find out the size of some expressions.
Code:
#include <stdio.h>
int main(void){
char a [100] = {0};
char (*p)[100] = &a;
printf("%d\n", sizeof a[0]);
printf("%d\n", sizeof &a[0]);
printf("%d\n", sizeof a);
printf("%d\n", sizeof p);
printf("%d\n", sizeof &a);
return 0;
}
The 1st expression is type char and I get 1
The 2nd is type char* (pointer-to-char), and I get 4--because of beeing on a 32 bits plataform, right?
The 3rd one is type char[100] (array-of-100-char), and I get 100
The 4th is type char(*)[100] (pointer-to-aray-of-100-char), and I get 4.
The last one is also type char(*)[100] (pointer-to-array-of-100-chars), but I get 100, shouldn't I get 4?
I've tested this progrman on an MS and on a Borland compiler. Both gave me the same result.
I've looked in various books and the standard and I think I should be getting 4, not 100.
What do you think?
Thanks.
Joey.