Well, if you don't need to make a copy of the list that you're adding, all you need to do is make the last node of the first list have its "next" member (or whatever you call it) point to the first node of the second list.
If you need to make copies of all the nodes in the second list, then you would do something like this:
pCurNode = &SecondList;
while ( pCurNode ) {
pEndofFirstList->next = new node; // or use malloc
pEndofFirstList->next->prev = pEndofFirstList;
pEndofFirstList = pEndofFirstList->next;
// copies all the data from pCurNode to pEndofFirstList
memcpy(pEndofFirstList, pCurNode, sizeof(node));
pEndofFirstList->next = NULL;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.