Hi.
I have an array of pointers (called g) that point to the dummy header of a linked list.
The linked list struct is as follows:
I have a separate int array, called e, which holds a number.Code:typedef struct node *node_ptr; struct node { int to_vertex; node_ptr next; };
What I am trying to do is to use a 'for loop' to travel along g, and at each element, look at the linked list it points to and decrement the number in the e array for each to_vertex in that linked list.
eg, e[0] holds the number 2.
if g[0] has a struct in its linked list with a to_vertex of 2, I want e[0] to become 1.
I keep getting a segmentation fault. Can you please tell me where I am going wrong.
Assuming i is the 'for loop' integer, and current has been declared as:
this is the area the seg fault occurs:Code:node_ptr current;
It is the line e[current->to_vertex]--; that causes the problem.Code:current = g[i]; while(current) { e[current->to_vertex]--; current=current->next; }
Thanks in anticipation of help
Cathy



LinkBack URL
About LinkBacks


