TIP: Click on subject to list as thread! ANSI
echo: cis.tandy.coco
to: all
from: Bob van der Poel 76510,2203
date: 1990-05-13 01:07:26
subject: #c-array initialization

#: 3441 S10/Tandy CoCo
    13-May-90  01:07:26
Sb: #c-array initialization
Fm: Bob van der Poel 76510,2203
To: all

Okay, time for my next "innocent 'C' question".

I would like to initialize an array of pointers so that each pointer points to
an array of values. For example, I can get the correct results by doing;

    char data[][3]={
       {1,2,3},
       {.....}

But this seems to be wasteful if the data are all constants. There is no need
for it to be transfered from the program area to the data area. I thought I
could do something like

    char *data[][4]={}

But of course, this sets up a double array of pointers. Not what I want. I
simply want a pointer to data[0][0], a second pointer to data[1][0], etc. Heck,
I'd even settle for a single dimensioned array with a pointer pointing to the
start of the whole mess. What I can't figure is how to define the data. It can
be done with strings...but what about values?



There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.