Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site uvacs.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!mcnc!ncsu!uvacs!rwl From: rwl@uvacs.UUCP (Ray Lubinsky) Newsgroups: net.lang.c Subject: Re: C declarations (with examples) Message-ID: <1827@uvacs.UUCP> Date: Tue, 29-Jan-85 20:25:08 EST Article-I.D.: uvacs.1827 Posted: Tue Jan 29 20:25:08 1985 Date-Received: Sun, 3-Feb-85 09:36:19 EST References: <7699@brl-tgr.ARPA> Organization: U.Va. CS in Charlottesville, VA Lines: 48 > I have a question about C declarations. The [] notation is equivalent > to the * notation, right? Well, not exactly. To declare something as ptr[] is to say that you want an array of objects of the type that you specify and that the identifier 'ptr' is to point to the zeroth element. Declaring *ptr only reserved 'ptr' to mean a pointer to that type. For example here are the errors I got on two test programs: % cat > test1.c < test2.c < Is this a desirable characteristic of C? What can I say? C will let you do all sorts of crazy things that you had no intention of doing (like accessing the 11th element of a ten-element array) but it won't let you risk losing all references to a block of allocated memory. Seems like a good idea to me. ------------------------------------------------------------------------------ Ray Lubinsky University of Virginia, Dept. of Computer Science uucp: decvax!mcnc!ncsu!uvacs!rwl