in c++ struct listrec value; int struct listrec next Write a main) routine in wh
ID: 3726233 • Letter: I
Question
in c++
Explanation / Answer
Please find my code.
void deepcopy(listrec *old_linked_list, listrec *&new_linked_list) {
listrec *temp = NULL, *head = NULL;
// iterating old_linked_list
while(old_linked_list != NULL) {
// creating new node
temp = (listrec *)malloc(sizeof(listrec));
temp->value = old_linked_list->value;
temp->next = NULL;
//
if(head == NULL) {
head = temp;
new_linked_list = head;
}else{
head->next = temp;
head = head->next;
}
old_linked_list = old_linked_list->next;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.