Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!tim From: tim@amdcad.AMD.COM (Tim Olson) Newsgroups: comp.unix.wizards Subject: Re: have I found a bug in K&R? Message-ID: <18668@amdcad.AMD.COM> Date: Tue, 13-Oct-87 11:46:52 EDT Article-I.D.: amdcad.18668 Posted: Tue Oct 13 11:46:52 1987 Date-Received: Thu, 15-Oct-87 00:37:07 EDT References: <517@hubcap.UUCP> <321@laticorp.UUCP> <7608@steinmetz.steinmetz.UUCP> Reply-To: tim@amdcad.UUCP (Tim Olson) Organization: Advanced Micro Devices Lines: 26 Keywords: argv definition Summary: You're both right In article <7608@steinmetz.steinmetz.UUCP> dawn!stpeters@steinmetz.UUCP (Dick St.Peters) writes: | In article <321@laticorp.UUCP> sarah@laticorp.UUCP (Sarah Groves Hobart) writes: | >Remember that the following declarations are equivalent: | > | >char s[]; | > | >char *s; | | Actually, they're not. The difference is like that between a constant | and a variable: you can change the value of s (the address it points | to) if you declare it as a pointer [variable], but you can't if you | declare it as an array [constant]. Consider what "&s" means in the | two cases. Actually, you are both right. There are two places where a declaration of an array with no size (and no initializer) are legal: 1) as a formal parameter, and 2) as an external array declaration, where the array is defined elsewhere. As a formal parameter, char s[] and char *s are equivalent -- the compiler coerces the former into the later. In that case you *can* change s. As an external array declartion, the two are not equivalent. -- Tim Olson Advanced Micro Devices (tim@amdcad.amd.com)