Path: utzoo!attcan!uunet!ncrlnk!ncr-sd!hp-sdd!hplabs!hpl-opus!hpccc!brown From: brown@hpccc.HP.COM (Jeffrey L. Brown) Newsgroups: comp.sys.ibm.pc Subject: Re: char ***pointer; Message-ID: <5060031@hpccc.HP.COM> Date: 14 Nov 88 23:59:09 GMT References: <360@mjbtn.MFEE.TN.US> Organization: Hewlett-Packard Corporate Computing Center Lines: 45 / hpccc:comp.sys.ibm.pc / root@mjbtn.MFEE.TN.US (Mark J. Bailey) / 4:29 pm Nov 13, 1988 / Hello, I have a question for the C gurus out there. It has to do with a pointer declaration and its subsequent use. I have declared: char ***pointer; Now I know that *ch is generally pointing to the start of a string, ie, a list (array) of characters. **ch would be equal to say a list of lists (or an array of strings, ie, **argv, for example). ***ch would support a list of lists of lists of characters. I suppose this could be associated with a two dimensional array of strings. My biggest question here is, when I declare a *ch and then call malloc to allocate a space for it to point to, I have a string. I can ch++ to move up the string. But when I have **ch, and subsequently, ***ch, do I have to call malloc to allocate space for more pointers? For example (using pointer above), pointer = (char ***) malloc((x)*sizeof(char *)); to allocate space for the *LIST* of pointers I am wanting to use? < rest of stuff deleted> --------------------- You are right about this method not working. What you said was "give me a one-dimensional array with x elements the size of char pointers. When I use it though, I will look 2 indirections through the array for my data, even though the pointers will go into space...." I get the idea that you want to support a table of pointers to strings, aka typedef char *STRING and STRING table[][]. I don't think my skill is refined enough to explain what to do and make it understandable. "Programming in C," by Lawrence Miller and Alexander Quilici, gives a very readable discussion on manipulating dynamic arrays of malloced strings; I think it would be easy to extend what they say to fit your problem. In particular, see chapter 8 which discusses how to allocate, traverse, and generally exploit these beasties. Jeff Brown HP Corporate Computing Center brown%hpccc@hplabs.hp.com