Initializing a pointer inside a struct

Andreas Gunnarsson f90angu at fy.chalmers.se
Wed Apr 17 20:51:39 AEST 1991


I've tried this:

struct
{
   ...
   int *int_list;
   ...
} list_of_structs[] =
{
   { ..., {1, 2, 3, -1}, ...},
   { ..., {4, -1}, ...},
   .
   .
   .
};

It doesn't work. I know I could declare the lists of integers as separate
variables and use the address, but it would be much harder to see what data
belongs where, and I would have to use *lots* of variable names.
I could also write 'int int_list[MAX];' instead of 'int *int_list;', but in
that case lots of space would be wasted if there is big variance in length.

Is there any simple way to do it?


-- 
==============================================================================
73 es 88 de SM7TLS          f90angu at fy.chalmers.se          Andreas Gunnarsson
==============================================================================



More information about the Comp.lang.c mailing list