[comp.lang.c] Arrays of pointers

wozniak@utkux1.utk.edu (Bryon Lape) (05/28/90)

	What I need to know is how to have a dynamic length array of
fixed length character strings.  Basically, I need an array of strings
14 characters long.  I tried
	char *array[14]
but this sets up an array for variable length strings (14 array
elements).  what I need is the opposite.  Any ideas?


-bryon lape-

PS- I now this was discussed a few months ago, but I failed to pay
attention since I did not need this info at that time.

diamond@tkou02.enet.dec.com (diamond@tkovoa) (05/29/90)

In article <1990May28.145851.2407@cs.utk.edu> wozniak@utkux1.utk.edu (Bryon Lape) writes:

>Basically, I need an array of strings 14 characters long.  I tried
>	char *array[14]
>what I need is the opposite.  Any ideas?

EVERY textbook on C will give you the idea.  Read one.  (Look for the
chapter on declarations.)

-- 
Norman Diamond, Nihon DEC     diamond@tkou02.enet.dec.com
Proposed group comp.networks.load-reduction:  send your "yes" vote to /dev/null.

e89hse@rigel.efd.lth.se (05/29/90)

In article <1990May28.145851.2407@cs.utk.edu>, wozniak@utkux1.utk.edu (Bryon Lape) writes:
>	What I need to know is how to have a dynamic length array of
>fixed length character strings.  Basically, I need an array of strings
>14 characters long.  I tried
>	char *array[14]
>but this sets up an array for variable length strings (14 array
>elements).  what I need is the opposite.  Any ideas?

 Try with:
	char (*array)[14];
 or maybe even
 	char (*array)[14+1];

 Henrik Sandell

als@bohra.cpg.oz (Anthony Shipman) (05/29/90)

In article <009375FB.7DA0D5C0@rigel.efd.lth.se>, e89hse@rigel.efd.lth.se writes:
> In article <1990May28.145851.2407@cs.utk.edu>, wozniak@utkux1.utk.edu (Bryon Lape) writes:
> >	What I need to know is how to have a dynamic length array of
> >fixed length character strings.  Basically, I need an array of strings
> >14 characters long.  I tried
> >	char *array[14]
> >but this sets up an array for variable length strings (14 array
> >elements).  what I need is the opposite.  Any ideas?
> 
>  Try with:
> 	char (*array)[14];
>  or maybe even
>  	char (*array)[14+1];
> 
>  Henrik Sandell

How does this sound?

typedef char string14[14];

string14	*list;
or
string14	list[] = {....};

At least this way I don't have to worry about precedence in type declarations.
-- 
Anthony Shipman                               ACSnet: als@bohra.cpg.oz.au
Computer Power Group
9th Flr, 616 St. Kilda Rd.,
St. Kilda, Melbourne, Australia
D

henry@utzoo.uucp (Henry Spencer) (05/29/90)

In article <1990May28.145851.2407@cs.utk.edu> wozniak@utkux1.utk.edu (Bryon Lape) writes:
>	What I need to know is how to have a dynamic length array of
>fixed length character strings...

Uh, what's a "dynamic length array"?  There is no such thing in C.
-- 
As a user I'll take speed over|     Henry Spencer at U of Toronto Zoology
features any day. -A.Tanenbaum| uunet!attcan!utzoo!henry henry@zoo.toronto.edu