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