Using sizeof() on a parameter array
Robert Earl
rearl at watnxt3.ucr.edu
Mon May 20 04:23:03 AEST 1991
In article <1991May19.135611.6332 at monu0.cc.monash.edu.au> ins845b at monu4.cc.monash.edu.au (mr k.l. lentin) writes:
| In article <12151 at jarthur.Claremont.EDU> jseidman at jarthur.Claremont.EDU (Jim Seidman) writes:
| >
| >void test(char param[80]) {
| > char local[80];
| >
| > printf("sizeof(param) = %d\n", sizeof(param));
| > printf("sizeof(local) = %d\n", sizeof(local));
| >}
| >
| 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.
No, since `param' has decayed to type `char *', sizeof(*param) returns
sizeof(char), which is 1.
--
______________________________________________________________________
\
robert earl / "Love is a many splintered thing"
rearl at watnxt3.ucr.edu \ --Sisters of Mercy
rearl at gnu.ai.mit.edu /
More information about the Comp.lang.c
mailing list