I think my head is going to explode. I cannot figure this out for the life of me. I'm trying to create two linked lists. No problem. But the second part is to merge them together into one list. This is where my headache comes from. Let's assume that the lists the user has entered are indeed in order. Now, we've got to turn these two lists into one list that is sorted. Each time comparing the data fields to see which one is less than or greater than the other. The function in my program that is giving me a headache is the "MergeLists" function. You'll see it below. Thanks for any help you guys can give.

#include <iostream.h>
#include <stddef.h>


struct DblNode
{
DblNode *Next;
DblNode *Prev;
int Data;
};



// Appends a node
void AppendNode(DblNode *curNode, DblNode* &fList, DblNode* &lList)
{
if (fList == NULL)
{
fList = curNode;
curNode->Prev = NULL;
}
else
{
lList->Next = curNode;
curNode->Prev = lList;
}
lList = curNode;
curNode->Next = NULL;
}

// Inserts a node into the list after pAfter

void InsertNode(DblNode* &curNode, DblNode* &pAfter, DblNode* &lList)
{
curNode->Next = pAfter->Next;
curNode->Prev = pAfter;
if (pAfter->Next != NULL)
pAfter->Next->Prev = curNode;
else
lList = curNode;
pAfter->Next = curNode;
}



void CreateList(DblNode* &fList, DblNode* &lList)
{
DblNode *curNode;
int pData;
cout << "Creating List...please input data\n";
for (;;)
{
cout << "Enter Data(-999 to quit): ";
cin >> pData;
if(pData==-999)break;
curNode = new DblNode;
curNode->Data = pData;
AppendNode(curNode, fList, lList);
}
cout << curNode;
}

void PrintList(DblNode* fListOne)
{
DblNode *curNode;
cout << "List:\n-----\n";
for (curNode = fListOne; curNode != NULL; curNode = curNode->Next)
{
cout << curNode->Data << endl;
}
cout << endl;
}
//Look, it's headache central!!!
void MergeLists(DblNode* &ResultList, DblNode* &fListOne, DblNode* &fListTwo)
{

ResultList = new DblNode;
DblNode *curResNode, *fcurNode, *scurNode;
curResNode = ResultList;
fcurNode = fListOne;
scurNode = fListTwo;
while(fcurNode->Next != NULL || scurNode->Next != NULL)
{
if(fcurNode->Data < scurNode->Data)
{
curResNode=fcurNode;
curResNode->Next=scurNode;
// curResNode->Next->Prev=curResNode;
}
else
{
// InsertNode(fcurNode, scurNode, lListOne);
}
fcurNode=fcurNode->Next;
scurNode=scurNode->Next;
curResNode = new DblNode;
}

}



void main()
{
DblNode *fListOne, *lListOne, *fListTwo, *lListTwo, *resList;
fListOne = NULL;
fListTwo = NULL;
lListOne = NULL;
lListTwo = NULL;
resList = NULL;
CreateList(fListOne, lListOne);
CreateList(fListTwo, lListTwo);
MergeLists(resList, fListOne, fListTwo);
PrintList(fListOne);
PrintList(fListTwo);
}