Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: net.lang.c Subject: Re: Address of array Message-ID: <2377@utcsri.UUCP> Date: Fri, 21-Mar-86 12:53:13 EST Article-I.D.: utcsri.2377 Posted: Fri Mar 21 12:53:13 1986 Date-Received: Fri, 21-Mar-86 13:05:08 EST References: <750@abic.UUCP> <2293@utcsri.UUCP> <313@hadron.UUCP> Reply-To: greg@utcsri.UUCP (Gregory Smith) Organization: CSRI, University of Toronto Lines: 44 Summary: In article <313@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes: >I don't really see what the problem is that people are moaning >about. If you want a pointer to the array, the array name itself >coerces to a pointer containing the memory location at the beginning ^^^^^^ ( right value wrong type. no cigar. ) >of the array. There is no such thing as a pointer to the whole >array: that is a Pasqualische or Fortranian notion. Pointers, in >C, only point to atomic or aggregate (structure/union) objects. Poppycock! char *char_ptr, (*char_ar_ptr)[80]; ++ char_ptr; /* add 1 to the actual value of char_ptr */ ++ char_ar_ptr; /* add _80_ to the actual value of char_ar_ptr */ /* i.e. point to the next array in a list */ IF I can have a pointer to an array, and dereference it to get an array, and increment it to point at the next array, WHY THE $@%@ CAN'T I POINT THE &#&*@&* THING AT AN ARRAY!!!!!!!?????????? ( nicely, I mean ) char line[80]; /* this is what I want to point it at */ char_ar_ptr = &line; /* this should work ... */ char_ar_ptr = line; /* this works, but gets a warning */ /* ( and rightly so ) */ char_ar_ptr = (char(*)[80])line; /* this works (big %$@%# deal) */ Furthermore, I don't buy the argument that array names are really load-time constants. I am mentioning this only because I have heard this argument more than once. I fail to see any logic underlying this; perhaps somebody treated array names as constants in some embryonic implementation of C because it worked for that definition of the language. No excuse. Anyway, array names are not always constants; any array which is local to a function has an address which is relative to the frame pointer. Also, in struct foo{ int foodle; char foo_line[80]; } *foo_ptr; the ARRAY foo_ptr->foo_line doesn't have a constant address, does it? The prosecution rests ( for now ). -- "No eternal reward will forgive us now for wasting the dawn" -J. Morrison ---------------------------------------------------------------------- Greg Smith University of Toronto ..!decvax!utzoo!utcsri!greg