From: Don DOT Sharp AT dddandr DOT octacon DOT co DOT uk (Don Sharp) Subject: Re: pointers &arrays[] 25 Nov 1997 07:27:54 -0800 Message-ID: <3479537F.4F304E35.cygnus.gnu-win32@dddandr.octacon.co.uk> References: <199711210929 DOT EAA01841 AT p2 DOT acadia DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Scott Warner Cc: gnu-win32 Scott Warner wrote: > > In a recent chat room discussion, pointer notation of arrays in C was > brought up. The question is, are array names pointers? Is array > subscripting another form of pointer notation, or visa-versa? I > realize > the pointer notation works for everything except sizeof() (and maybe > others). So that > > array == &array[0] > array == &array > *array == array[0] > *(array+n) == array[n] > > are all true given array[n]. In this case, sizeof(array) returns the > size > of the entire array, not array[0]. Are there other examples where > this > pointer notation fails? > Lastly, is this pointer notation implementation dependent or is it > part of > the de facto standard? > Pointers and array names are only EXACTLY equivalent (in C) when used as arguments to functions. Most compilers preserve this assumption outside that case but don't have to. I've been caught out at link time by referencing extern char *freddy_the_freeloader; when it had in fact been declared as char freddy_the_freeloader[] = "nice jazz tune"; the linker quite rightly ruled that they are not the same thing! Cheers Don Sharp - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".