C program - (please read the requirement carfully) Write a function called copyL
ID: 3789904 • Letter: C
Question
C program
-
(please read the requirement carfully)
Write a function called copyList (), which makes a "deep" copy or complete copy of one singly linked list. The function should accept two parameters: a pointer to the source list and a pointer to the new list. You need to decide if the pointer to the new list is single indirection (*) or double indirection (**). The function should not return a value. You should NOT just do the following: newList = sourceList;//pseudocode You may not assume that a makeNode () function exists. A Node is defined as follows: typdef struct node {char data[100]; struct node *pNext;} Node; Be sure to fill in the function header! void copyList(Node *pSourceList, ) {Explanation / Answer
void CopyList(Node* pSourceList, Node* ©) { while (pSourceList != NULL) { { Node* copy = new Node; copy->data= pSourceList->data; copy->pNext = pSourceList->pNext; pSourceList = pSourceList->pNext; } } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.