I'm getting a seg fault and I can't work out why.
Code:
int add_node(void){
struct list *temp;
// Go to end of list
current = &head;
if(current){
while(current){
current = current->next;
}
}
else return 1;
// Allocate memory
temp = malloc(sizeof(struct list));
if(!temp)
return 1;
temp->next = NULL;
//current->next = temp; /* This line gives me the seg fault */
return 0;
}
It looks good to me but it's late and I can't work out why this isn't working. If more code is needed, just ask.
[edit]
nevermind, I fixed it. (I seem to do this a lot dont I?)