Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!uwvax!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: char (*a)[] (was: Style [++i vs i++]) Message-ID: <7953@mimsy.UUCP> Date: Wed, 12-Aug-87 10:58:54 EDT Article-I.D.: mimsy.7953 Posted: Wed Aug 12 10:58:54 1987 Date-Received: Sat, 15-Aug-87 01:48:07 EDT References: <8298@brl-adm.ARPA> <587@cblpe.ATT.COM> <189@xyzzy.UUCP> <234@nvpna1.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 28 In article <234@nvpna1.UUCP> strouckn@nvpna1.UUCP (Louis Stroucken) writes: >Please note that "a" is a formal argument of main!! >K&R appendix A section 10.4 says on array arguments: > ...formal parameters declared "array of..." are adjusted to read > "pointer to...". >The declaration of "a" might as well read "char **a;". "a++;" should >increment "a" with sizeof( char * ) bytes. The type of `a' in `char (*a)[]' is `pointer to array of char'. Aside from the fact that pointers to arrays of unspecified size are illegal[1], this declaration is correct and cannot be altered. The adjustment is for formal parameters declared `array ...', not `... array ...'. The single ellipsis means that the array type must come first. ----- [1]This illegality is in fact unnecessary; a pointer to an array of unspecified size can be dereferenced. It cannot be used in any pointer arithmetic except to add or subtract zero. Nonetheless it was deemed illegal, and this loses nothing, since C does not have dynamic arrays. (C has dynamic memory allocation, but what you get are flat blocks of address space, though they are not necessarily contained within a globally flat space.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: seismo!mimsy!chris