Serve Laurijssen wrote:
Given this structure:
typedef struct S
{
struct Inner {
char desc[128];
char *file[MAX_PATH+1];
} *libs;
} S;
The Inner struct has a description string and an array of file strings. I
know the the max length of each file upfront, but not how many files go in
there. As you can see file is now declared as an array of MAX_PATH+1 char
pointers, but I want a dynamic array of static char array. (pfff)
How do I declare and assign to that?
As far as declaration, what about
char (*file)[MAX_PATH + 1];
When you find out how many strings you are going to want to store, you
can use:
file = malloc(sizeof *file); /* easy enough */
and to copy your data, presumably stored filename:
char *filename;
/* fill filename out by whatever means */
strcpy(file[2], filename);
Voila !
--
Bertrand Mollinier Toublet
Currently looking for employment in the San Francisco Bay Area
http://www.bmt.dnsalias.org/employment