Array of pointers

From NuclearCat's homepage

Revision as of 10:12, 7 August 2008 by Nuclearcat (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Not sure if it is right.

struct testarr {
 int a;
 int b;
} **macarr;

/* Allocate memory for pointers array */
macarr=malloc(sizeof(struct testarr*)*HOW_MUCH_POINTERS);

/* Allocate memory for structures */
macarr[0] = malloc(sizeof(struct testarr));
macarr[1] = malloc(sizeof(struct testarr));
Personal tools