C Structure initialization (Array of integers and an integer value) -
#define max 10 struct setarray { int item[max]; int count; }; typedef struct setarray *bitset;
how should initialize elements in structure?
for example
struct setarray s = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, max };
or
struct setarray s; ( int = 0; < max; i++ ) s.item[i] = i; s.count = max;
or
bitset p = malloc( sizeof( *p ) ); ( int = 0; < max; i++ ) p->item[i] = i; p->count = max;
Comments
Post a Comment