#: 15754 S12/OS9/68000 (OSK)
03-Jul-92 00:20:57
Sb: #15751-Pointer help
Fm: Pete Lyall 76703,4230
To: Bob van der Poel 76510,2203 (X)
Bob -
If you're looking to allocate a dynamically sized array, then you pretty much
MUST use malloc() (or a variation).
Example:
Allocate an array of pointers to type int. The array will be 'num_required'
long:
num_required = 49; /* or whatever */
.....
int *array_ptr; /* pointer to a type of int */
array_ptr = malloc(num_required * (sizeof (int *)));
You now have an array of pointers to int that may be accessed either in the
form array_ptr[0...num_required-1] or array_ptr+0...num_required-1.
Pete
|