Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c Subject: Re: arrays of pointers - NOVICE QUESTION!( Be forwarned ! ) Keywords: pointers, arrays Message-ID: <1743@auspex.auspex.com> Date: 5 Jun 89 18:02:31 GMT References: <10971@orstcs.CS.ORST.EDU> <1163@draken.nada.kth.se> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 29 >The first and the second declarations are identical for all normal uses >as long as you leave the size of the array out i.e. >char *foo[] == char **foo Wrong! The first and the second declarations are identical only when used to declare a formal argument to a procedure. >The ** stands for "pointer to pointer", and since the first pointer >can be temporarily incremented using an "index", this pointer could >as well be a pointer to an array of pointers. The difference is >syntactical -- char *foo[] may be used in formal declarations/parameters >only! Wrong. extern char *foo[]; is perfectly legitimate, for example, and is a declaration of an array of pointers to "char" that is defined elsewhere. The *definition* has to specify a size for the array, but the *declaration* doesn't. >Also, the char *argv[] works, the char **argv doesn't, on my machine >(Speaking of main(argc, argv), that is...) This might be a bug in the >* ancient * compiler I use. "Might be a bug"? It definitely *is* a bug! The "char **argv" is a perfectly legitimate declaration, and if the compiler you use can't handle it, it's broken (and wouldn't be able to cope with a *lot* of code out there).