Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!munnari.oz.au!bruce!monu0.cc.monash.edu.au!monu4!ins845b From: ins845b@monu4.cc.monash.edu.au (mr k.l. lentin) Newsgroups: comp.lang.c Subject: Re: Using sizeof() on a parameter array Message-ID: <1991May19.135611.6332@monu0.cc.monash.edu.au> Date: 19 May 91 13:56:11 GMT Article-I.D.: monu0.1991May19.135611.6332 References: <12151@jarthur.Claremont.EDU> Sender: ins845b@monu4.cc.monash.edu.au (kevin lentin) Organization: Monash University, Clayton, Vic 3168, Australia Lines: 26 In article <12151@jarthur.Claremont.EDU> jseidman@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