Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

how do you make a copy of a linked list in c

struct node *copyList(struct node *sourceList)
{
    if(sourceList==NULL) return;
    struct node *targetList=(struct node *) malloc(sizeof(struct node));
    targetList->info=sourceList->info;
    targetList->link=copy(sourceList->link);
    return targetList;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #copy #linked #list
ADD COMMENT
Topic
Name
6+7 =