typedef struct {
int size;
} A, *pA;
typedef struct {
int size;
} B, *pB;
//and so on...
//Now your list can be a collection of these
typedef struct {
A a;
B b;
//additional members if defined
} LIST;
LIST list[20], *pList; //[edited to make array of LIST]
//prototype List function
LIST * updateList(LIST *a);
int main(void)
{
pList = &list[0]; //[edit to init pointer to array of lists
//access and use pointers to list as necessary
LIST *b = updateList(pList);
//Use the updated list here
printf( "b[0].a.size is: %d\n" , b[0].a.size);
printf( "b[1].a.size is: %d\n" , b[1].a.size);
printf( "b[2].a.size is: %d\n" , b[2].a.size);
printf( "b[3].b.size is: %d\n" , b[3].b.size);
printf( "b[4].b.size is: %d\n" , b[4].b.size);
printf( "b[5].b.size is: %d\n" , b[5].b.size);
return 0;
}
LIST * updateList(LIST *a)
{
//do some manipulations to LIST here...
a[0].a.size=1;
a[1].a.size=2;
a[2].a.size=3;
//and so on.
a[3].b.size=4;
a[4].b.size=5;
a[5].b.size=6;
//and so on.
return a;
}
这对你有用吗?