Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!zaphod.mps.ohio-state.edu!think.com!compass!worley From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.c Subject: Re: Using sizeof() on a parameter array Message-ID: Date: 20 May 91 15:10:36 GMT References: <12151@jarthur.Claremont.EDU> Sender: root@compass.com Organization: Compass, Inc., Wakefield, MA, U.S.A. Lines: 33 In-reply-to: jseidman@jarthur.Claremont.EDU's message of 18 May 91 16:25:02 GMT In article <12151@jarthur.Claremont.EDU> jseidman@jarthur.Claremont.EDU (Jim Seidman) writes: void test(char param[80]) { char local[80]; } Yes, the type of 'param' is 'char *'. See section 3.7.1 of the ANSI standard. This makes is hard to pass arrays as arguments. However, if you wrap the array in a struct, the array will be passed as requested! struct dummy { char a[80]; }; void test(struct dummy param) { printf("sizeof(param) = %d\n", sizeof(param)); } will print 80 as expected! Dale Dale Worley Compass, Inc. worley@compass.com -- Q: Why does Internet raise issues of academic freedom and free speech? A: Anything you can write publish, broadcast, or yell from the top of a building, Internet can propagate further, faster, more elegantly. Thus, age-old issues of freedom of speech and expression vs. public safety and moral sensibilities have moved into this high tech arena. -- Joe Abernathy [And in an intensified form.]