Hey everyone,

I need to make an array of pointers to struct that can be dynamically
resized.  Right now i have this:

typedef struct _screenfields
{
  unsigned int totalfields;
  field5250 fields[1782];
} screenfields;

screenfields *fields5250[10];

I need to make the fields5250 array be dynamic (instead of only 10
elements).  I think I need to do:

screenfields **fields5250;

I don't know how to do the malloc() properly for that, though.  Currently
for my static array of pointers I do this:

  fields5250[0] = (screenfields *) malloc (sizeof (screenfields));

Which works great.  I think I should be able to keep the same statement to
allocate each element using a dynamic array, but I don't know how to
allocate the array itself.  I think I don't have to allocate the array
itself at all, since the array is just a pointer to the first element in
the array.  But it's been seg faulting, so I think I'm doing something
wrong.

James Rich

Zvpebfbsg vf abg gur nafjre.
Zvpebfbsg vf gur dhrfgvba.
AB (be Yvahk) vf gur nafjre.
        -- Gnxra sebz n .fvtangher sebz fbzrbar sebz gur HX, fbhepr haxabja

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact [javascript protected email address].