January 3rd, 2013, 05:53 PM
Join Date: Nov 2012
Time spent in forums: 1 Day 7 h 16 m 14 sec
Reputation Power: 2
Segmentation fault with linked list
i'm currently taking my first steps with linked list, and i'm having a problem:
whenever i run the program it terminates and mumbles somthing about segmentaion fault.
from what i've read, it means the program tried to access an unauthorized memory block.
i just couldn't figure out what's wrong with the code, and i can really use some help.
here's the code:
struct numbers *next;
void Append(struct numbers **headRef, int num)
struct numbers *current;
struct numbers *newNum;
newNum=(struct numbers *)malloc(sizeof(struct numbers));
//case of first node
current->next=newNum; //it always fails here, at the second call to Append
struct numbers *head=NULL;
struct numbers *conductor;
for (i=1; i<6 ;i++)
it always fails at the same code line (marked in red).
thanks in advanced!