I just started working with linked lists and structures and am very new to coding. The following code is a function that when called adds a new dog to the structure of dogs. I don't get a segmentation fault when entering the first dog but only when I enter another dog do I get this issue. I'm not sure how to fix this so any help would be much appreciated.
if(list == NULL){
list = new_node;
return list;
}
while(p->next != NULL){
p = p->next;
}
p->next = new_node;
return list;
}