Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.wizards,comp.lang.c Subject: Re: have I found a bug in K&R? Message-ID: <29486@sun.uucp> Date: Tue, 29-Sep-87 21:43:02 EDT Article-I.D.: sun.29486 Posted: Tue Sep 29 21:43:02 1987 Date-Received: Thu, 1-Oct-87 05:44:40 EDT References: <517@hubcap.UUCP> Sender: news@sun.uucp Followup-To: comp.lang.c Lines: 20 Keywords: argv definition Xref: mnetor comp.unix.wizards:4577 comp.lang.c:4637 (This is a C question, not a UNIX question.) > on page 110 of K&R it says: > > "...(argv) is a pointer to an array of character strings..." > > but since the primary-expression operator [] has higher priority than > the unary operator *, then isn't it more correct to say that argv > (which is defined as char *argv[]) is an array of pointers to character > strings? No, it is more correct to say that "argv" is a pointer to the first element of an array of pointers to "char", which can be read as "'argv' is a pointer to the first element of an array of pointers to character strings". "argv" is *properly* declared as "char **argv"; however, if you declare an array of type X as an argument to a function, the compiler interprets that as a declaration of a pointer to type X instead. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com