Hi I'm trying to read variables from a file into a int array so I can store them in a Struct array. The numbers get stored correctly into the curLinks array but when I try pass the curLinks array into curNodes.nodes, it doesn't work and when i try print it out (to test) it prints rubbish numbers. Any help would be great.
struct nodeInfo* getTopology(FILE *file){
int totLinks=0;
fscanf(file, "%d", &nodeCount);
struct nodeInfo netTopo[nodeCount];
// How many links does node have
for (int id=0; id<nodeCount; id++){
struct nodeInfo curNode;
curNode.n=id;
fscanf(file, "%d", &totLinks);
int curLinks[totLinks];
for(int i=0; i<totLinks; i++){
int digit=0;
fscanf(file, "%d", &digit);
curLinks[i] = digit;
}
curNode.nodes = curLinks;
netTopo[id] = curNode;
}
for (int id=0; id<nodeCount; id++){
for (int j=0; j<3; j++){
printf("%d ", netTopo[id].nodes[j]);
}
}
return netTopo;
}