Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!brutus.cs.uiuc.edu!apple!rutgers!rochester!kodak!ektools!randolph From: randolph@ektools.UUCP (Gary L. Randolph) Newsgroups: comp.lang.c Subject: Re: "array" vs. "&array" ? Message-ID: <2368@ektools.UUCP> Date: 3 Jan 90 14:03:14 GMT References: <1989Dec22.013757.3086@sj.ate.slb.com> <571@mwtech.UUCP> <21419@mimsy.umd.edu> <1989Dec28.100415.17825@eng.umd.edu> Sender: randolph@ektools (Gary L. Randolph) Reply-To: randolph@ektools.UUCP (Gary L. Randolph) Organization: Eastman Kodak, Dept. 47, Rochester NY Lines: 39 In article <1989Dec28.100415.17825@eng.umd.edu> dskim@eng.umd.edu (Daeshik Kim) writes: >In article <21419@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: >> >> &arr >> >>produces either a warning (Classic C), or a value of type `pointer >>to array SIZE of basetype' (New C). >> >> >>> p = &a; >> >>Unfortunately, when handed to an Old C compiler, you get: >> >>>warning: & before array or function: ignored >>>warning: illegal pointer combination, op = >> > > If I define "char a[10];" and use " &a" (e.g. address of array a) > , isn't this undefined? ***> That depends upon which generation of C compiler you are using!!! ***> Unfortunately, there are *THREE* reactions a C compiler may have ***> to taking the address of an array name. ***> 1.) Compilers strictly conformant to K&R C will generate an error ***> to indicate that &array_name is undefined. ***> 2.) Since the novice C programmer made this mistake so frequently, ***> compiler vendors 'got nice' and simply generated a warning and ***> informed you that the '&' was ignored. (How kind!?) ***> 3.) ANSI extended the language definition to allow taking the ***> address of an array name, so an ANSI conformant compiler will ***> now (correctly) yield pointer to array of T, or pointer to ***> pointer to T. ***> IMHO, this extension is reasonable, though I have not found a place ***> for it in the applications on which I have worked. Gary