So in this snippet of C code, I have this situation which I don't fully comprehend. Basically, I want to modify the "tics" value inside of the newNode struct. The value I need to assign to it is "newAssignment." When I try to run this code, however, I get a seg-fault. The segfault doesn't occur EVERY time this code is ran, but it does get a seg-fault when temp-> next is null.
How do I assign newAssignment to newNode->tics without seg-faulting?
while(newNode->tics > temp->tics){
int newAssignment = newNode->tics - temp->tics;
newNode->tics = newAssignment;
if(temp->next == NULL){
break;
}
temp = temp->next;
}