E
Erik S. Bartul
lets say i want to fill up a multidimentional array, but i wish to allocate
memory for it on the fly.
i assume i declare,
char **a;
but how do i allocate memory for the pointers, so i can then allocate to the
pointers to which those pointers point?
essentially lets say i during runtime deturmine i must allocate space for 60
pointers,
a = malloc(size of(char *) * 60);
what is this in effect allocating for?
and subsequently when i wish to allocate memory for a pointer to which one
of the pointers point,
a[0] = malloc(128); /* to allocate to the first pointer in the array of
pointers, 128 bytes */
im probably overlooking something very simple, and it comes to mind that ive
been in this pickle awhile back... i just cant seem to remember what that
solution was. and i have read over the C faq.
memory for it on the fly.
i assume i declare,
char **a;
but how do i allocate memory for the pointers, so i can then allocate to the
pointers to which those pointers point?
essentially lets say i during runtime deturmine i must allocate space for 60
pointers,
a = malloc(size of(char *) * 60);
what is this in effect allocating for?
and subsequently when i wish to allocate memory for a pointer to which one
of the pointers point,
a[0] = malloc(128); /* to allocate to the first pointer in the array of
pointers, 128 bytes */
im probably overlooking something very simple, and it comes to mind that ive
been in this pickle awhile back... i just cant seem to remember what that
solution was. and i have read over the C faq.