How to create a copy of a linked list? Write a C program to create a copy of a linked list.

October 28, 2007 · Filed Under Linked List, Placement Questions 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

Check out this C program which creates an exact copy of a linked list.

copy_linked_lists(struct node *q, struct node **s)
{
if(q!=NULL)
{
*s=malloc(sizeof(struct node));
(*s)->data=q->data;
(*s)->link=NULL;
copy_linked_list(q->link, &((*s)->link));
}
}

Related Articles


Get Latest JobsAdda.com Jobs, news & updates  via Email