Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!DHowell.ElSegundo@Xerox.COM From: DHowell.ElSegundo@Xerox.COM Newsgroups: comp.lang.c Subject: Re: char (*a)[] (was: Style [++i vs i++]) Message-ID: <8942@brl-adm.ARPA> Date: Fri, 21-Aug-87 17:56:44 EDT Article-I.D.: brl-adm.8942 Posted: Fri Aug 21 17:56:44 1987 Date-Received: Sun, 23-Aug-87 03:23:41 EDT Sender: news@brl-adm.ARPA Lines: 56 In article <1347@dataio.Data-IO.COM> bright@dataio.Data-IO.COM (Walter Bright) writes: >In article <234@nvpna1.UUCP> strouckn@nvpna1.UUCP (Louis Stroucken 42720) writes: >>In article <1987Aug10.192923.7879@sq.uucp> msb@sq.UUCP (Mark Brader) writes: >>>Regarding the code... >>>> > main(a) >>>> > char (*a)[]; >> [ discussion wether "a++;" should do something sensible ] >>> >>>Actually, *declaring* such a pointer is probably illegal. >>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. >> >>If I miss something, please let me know. > >The declaration: > char (*a)[]; >means: > 'a' is a pointer to an array of chars, the size of the array > is unknown. >Since 'a' is not an "array of...", it is not adjusted to "pointer to..." >and is not equivalent to "char **a;". > >Expressions of the form (*a)[n] are legal, however, since the compiler >does not need to know the size of the array to compile it. I'm confused. Suppose I declare: char (*a)[10]; char b[10]; Now b is an array of size 10 of char, and a is a pointer to an array of size 10 of char. So this means I should be able to say: a = &b; However, as I understand it, b is actually &b[0], which means a gets set to &&b[0], which I'm not sure makes any sense at all. What exactly does a point to? Does it point to the first element of an array? Does it point to a descriptor of an array? How would I assign anything useful to a, if I can't use the above type of assignment? Or is the assignment valid? If so what is the meaning of &b? Dan