Hello all,
I have a question about arrays of variable length. This is what I would like to do. I have two structures A and B
struct A
{
int a;
int b;
struct A * pSubA;
};
struct B
{
int c;
int d;
struct A * pSubA;
};
The idea behind this is that B holds n objects of A and A also can hold n objects of type itself.
Now how do I statically intialize an object of type B as follows -->
struct B ob[] =
{
{1,1,NULL},
{1,2,NULL}
};
This seems to work. But how do I do the following -->
struct B ob[] =
{
{1,1,{{1,1,NULL},{1,1,NULL},{1,1,NULL}}},
{1,1,NULL}
};
Meaning how do I assign an array of values to the pSubA pointer. The reason for this is that B can hold more than 1 object of type A.
Also how do I do the following -->
struct B ob[] =
{
{1,1,{{1,1,{{<another A here>}, {<Another A>}}},{1,1,NULL},{1,1,NULL}}},
{1,1,NULL}
}
Appreciate any help.... Thanks in advance