#char (*tp[N])[] ?
08-Aug-93 00:13:22
Sb: #36235-#char (*tp[N])[] ?
Fm: Jeff Pratt 76057,3645
To: Dale Larson 76702,654
Well, I did figure out how to do what I needed to do — partly, "realized
there was an easier way…":
#define NF 3
char *fruits[NF] = {"Apples", "Oranges", "Bananas"};
#define NV 4
char *vegetables[NV] = {"Carrots", "Brocoli", "Turnips", "Rutabagas"};
#define NP 2
char **plants[NP] = { fruits, vegetables };
#define NGROUPS 2
int nkinds[NGROUPS] = { NV, NP };
/* print out foods: */
int n, i;
char **name_ptr;
for(n=0;n<NGROUPS;n++) {
name_ptr = plants[n];
for (i=0;i<nkinds[n];i++)
printf("\n I like to eat %s", *name_ptr++ );
}
…. this is a simplified example. The use for it is to organize and
access some file-names, along with a variable number of field-names for
each file. (plus some other arrays for file & field handles, etc….)
thanks for the suggestions.
(auto-piloted from)
JcP