www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/04/05:12:45

From: "Andrew Davidson" <andrew AT lemure DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Array question (a little bit newbie)
Date: Wed, 3 Mar 1999 10:04:06 -0000
Organization: Customer of Planet Online
Lines: 25
Message-ID: <7bllsm$vap$1@news5.svr.pol.co.uk>
NNTP-Posting-Host: modem-14.neodymium.dialup.pol.co.uk
X-Trace: news5.svr.pol.co.uk 920541910 32089 62.136.29.142 (4 Mar 1999 10:05:10 GMT)
NNTP-Posting-Date: 4 Mar 1999 10:05:10 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.0810.800
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'm having a spot of bother defining an 'unsized' array of char pointers.
What I want is an array filled with pointers to pointers to a list of chars,
a little like:

char *mylist[]= {
"item 1", "item 2", "item 3"
};

(incidentally, why can't I get a compile on char **mylist= {"item1", "item
2","item3"}; if I can do char **argv in main()? )

The difference is I don't want a list of pointers to strings, I want
pointers to lists of chars of varying length.
Oh and while I'm at it is there any way of calculating the length of any of
these lists without using terminating characters or placing a byte count at
the front of each list? Would sizeof(mylist[<list number>]) work?

Thanks for you time, sorry to be so unclued about such a basic point. I've
tried looking it up in a couple of C manuals but they don't seem to be
interested in anything past string arrays... Maybe I ought to buy a new
book.

Andrew


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019