Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!ucsd!ucrmath!rearl From: rearl@watnxt3.ucr.edu (Robert Earl) Newsgroups: comp.lang.c Subject: Re: Using sizeof() on a parameter array Message-ID: Date: 19 May 91 18:23:03 GMT References: <12151@jarthur.Claremont.EDU> <1991May19.135611.6332@monu0.cc.monash.edu.au> Sender: news@ucrmath.ucr.edu Organization: (EVIL!) Lines: 24 In-reply-to: ins845b@monu4.cc.monash.edu.au's message of 19 May 91 13:56:11 GMT In article <1991May19.135611.6332@monu0.cc.monash.edu.au> ins845b@monu4.cc.monash.edu.au (mr k.l. lentin) writes: | In article <12151@jarthur.Claremont.EDU> jseidman@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@watnxt3.ucr.edu \ --Sisters of Mercy rearl@gnu.ai.mit.edu /