E
estantep
Hello,
I am having some trouble trying to pass a pointer to an structure
array (as function argument), when executing I get seg faults.
The best I could get out from googling was:
#define MAX_GRAPH 256
typedef struct edge{
long delay;
long bandw;
} edge;
edge link[MAX_GRAPH][MAX_GRAPH];
int print_structure(edge *graph[MAX_GRAPH][MAX_GRAPH]){
int i, j;
for(i=0;i<nodes;i++){
for(j=0;j<nodes;j++){
printf("[%d][%d].bandw = %d\t\t", i, j, graph[j]->bandw); //
SEG FAULT!
printf("[%d][%d].delay = %d\n", i, j, graph[j]->delay);
}
}
return 0;
}
int main(int argc, char* argv[]){
....
print_structure(link);
....
}
Could anybody help me spot the problem?
Thanks,
Paulo
I am having some trouble trying to pass a pointer to an structure
array (as function argument), when executing I get seg faults.
The best I could get out from googling was:
#define MAX_GRAPH 256
typedef struct edge{
long delay;
long bandw;
} edge;
edge link[MAX_GRAPH][MAX_GRAPH];
int print_structure(edge *graph[MAX_GRAPH][MAX_GRAPH]){
int i, j;
for(i=0;i<nodes;i++){
for(j=0;j<nodes;j++){
printf("[%d][%d].bandw = %d\t\t", i, j, graph[j]->bandw); //
SEG FAULT!
printf("[%d][%d].delay = %d\n", i, j, graph[j]->delay);
}
}
return 0;
}
int main(int argc, char* argv[]){
....
print_structure(link);
....
}
Could anybody help me spot the problem?
Thanks,
Paulo