Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!kth!draken!d88-jwa From: d88-jwa@nada.kth.se (Jon W{tte) Newsgroups: comp.lang.c Subject: Re: arrays of pointers - NOVICE QUESTION!( Be forwarned ! ) Keywords: pointers, arrays Message-ID: <1163@draken.nada.kth.se> Date: 4 Jun 89 14:51:35 GMT References: <10971@orstcs.CS.ORST.EDU> Reply-To: h+@nada.kth.se (Jon W{tte) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 30 In article <> flatmas@ladder.CS.ORST.EDU (Scott Flatman) writes: >Recently someone posted a remark that these two declarations are the same: >char *array[some size - you choose]; >and >char **array; >My understanding is that the first declaration is for an array of pointers to >char. The second one is confusing me. How is it interpreted? 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 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! 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. Be warned ! IF you specify a size within the brackets, the compiler reserves memory for your array, but if you use **, you have to do the memory allocation yourself using malloc() (Or, on certain systems, mreserve(), NewHandle(), getmem() ...) I hope this clarifies at least some of your questions. Flames may be sent to /dev/null or your local fortune cookie administrator. -- __ Jon W{tte (The dread Smiley Shark) email:h+@nada.kth.se / \ (+46 (0) 8 258 268) /--- (c) 1989 Yessbox Allright Professional Products Inc. - Y.A.P.P.I. / -- No More --