Using sizeof() on a parameter array
mr k.l. lentin
ins845b at monu4.cc.monash.edu.au
Sun May 19 23:56:11 AEST 1991
In article <12151 at jarthur.Claremont.EDU> jseidman at jarthur.Claremont.EDU (Jim Seidman) writes:
>
>I ran into this using Microsoft C 6.00A, and wanted to know if this was
>a bug in MSC or the way an ANSI C compiler really should work. Consider
>the following function:
>
>void test(char param[80]) {
> char local[80];
>
> printf("sizeof(param) = %d\n", sizeof(param));
> printf("sizeof(local) = %d\n", sizeof(local));
>}
>
>Now, I thought that this should print out the same size for both, namely
>80. But according to MSC, local has a size of 80, and param has a size
>of 2 (the size of a pointer).
>
>The ANSI K&R doesn't address this issue explicitly. Any definitive
>answers on what should happen?
>
C passes all arrays as pointers and as a stringis an array, it is passed
as a pointer. I am not sure but sizeof(*param) MIGHT return 80 but
sizeof(param) should return 2 as I can see it.
|/
|\evin
More information about the Comp.lang.c
mailing list