copy doubly linked list

so i have a doubly linked list and i want to copy it.
how do i do that??

1
2
3
4
5
6
7
8
9
10
11
12
13
struct node{

	string data;
	node* next;
	node* prev;
};

struct list{

        node* head;
	node* tail;
};


so i have two structures one is the one for the nodes, containing a string and the two pointers. and the other one contains the head and tail pointers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

int main(){

list* L[10]; //creates new array of lists 

//assume L[0] is already created.
L[1] = copyList(L[0]);


return 0;
}

list* copyList(list* original){  //this will be the function to call 

// here it takes original, makes a copy of it and returns the new list.
}



thanks!!


Topic archived. No new replies allowed.