Hello,
This structure needs to be dynamic allocated. For instance,
In this example, MaxNodes has been defined before structname. Now, if want to made strucname dynamic allocation (because the number of structname may exceed NUM=10). The matrix[NUM][NUM] is the problem. This one shouldn't work
This structure needs to be dynamic allocated. For instance,
Code:
#define NUM 10
struct node {
char *NodeName;
int index;
}
struct structname {
struct node nodes[NUM];
bool matrix[NUM][NUM];
int nNodes;
};
In this example, MaxNodes has been defined before structname. Now, if want to made strucname dynamic allocation (because the number of structname may exceed NUM=10). The matrix[NUM][NUM] is the problem. This one shouldn't work
Code:
typedef structname *strucptr;
structptr DynaStruct;
DynaStruct = (strucptr *) malloc(1 * sizeof(structptr));