You do it:
while (true){ if (current == NULL){ temp = NULL; break; } temp->number = current->number; current = current->next; temp = temp->next; }
Suppose it works the way you planned. When while exists, temp will be NULL , right?
listpointer = temp; <=> listpointer = NULL;
So this can be a problem.
source share