Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!nuug!ifi!enag From: enag@ifi.uio.no (Erik Naggum) Newsgroups: comp.lang.c Subject: Re: Difference between "char *arr" and "char arr[]" Message-ID: Date: 24 Sep 90 23:00:04 GMT References: <8103@aggie.ucdavis.edu> <26680@mimsy.umd.edu> Sender: enag@ifi.uio.no (Erik Naggum) Organization: Naggum Software, Oslo, Norway Lines: 36 Nntp-Posting-Host: hild.ifi.uio.no In-Reply-To: chris@mimsy.umd.edu's message of 24 Sep 90 06:03:02 GMT Originator: enag@hild In article , Erik Naggum (I) wrote: > Let me venture a concise explanation to this difference: > > extern char *arr declares an object, containing a > pointer to a character > > extern char arr[] declares a constant pointer to a > character In article <26680@mimsy.umd.edu>, Chris Torek (you) write: > Concise, yes; correct, no. Both declare objects; the latter declares > an object that is an array. It IS an array; it is NOT a pointer. The > confusion occurs because objects that are arrays are *converted into* > VALUES that are pointers, whenever the value is called for. Rather, "char arr[14]" declares an array, but "extern char arr[]" only declares that "arr" is some constant pointer the value of which is to be resolved by the linker. "char *arr" declares an object, and "extern char *arr" declares that "arr" is some object the address of which is to be resolved by the linker. I think you overlooked the "extern" up there. I follow your arguments for locally declared objects down to the finest details. Strictly speaking, I have to correct my own explanation: Neither declares objects, but instead object names with types and values of that type to be resolved by the linker (or later, anyhow). I hope this gets a "concise, no; correct, yes" response, at least. -- [Erik Naggum] Naggum Software; Gaustadalleen 21; 0371 OSLO; NORWAY I disclaim, , therefore I post. +47-295-8622, +47-256-7822, (fax) +47-260-4427