Well I will give some code because (A) I just woke up and this code is just a quick attempt. And (B) I believe the best way to learn programming is to study others source code. But please don't just use the code try to understand what it is doing cause that is what will make you a programmer not just pasting others code ok. :)
Node* mergeLists(Node* list1, Node* list2)
{
Node *merged = createList(10);
while(list1 != 0 || list2 != 0)
{
if (list1 != 0)
{
merged = insertOrdered(merged, list1->element);
list1 = list1->next;
}
if (list2 != 0) {
merged = insertOrdered(merged, list2->element);
list2 = list2->next;
}
}
return merged;
}
also I added these to the start of the code because I was getting error C3861: 'createList': identifier not found.
void printList(Node *head);
Node* insertOrdered(Node *head, int x);
Node *createList(int x);
Node* mergeLists(Node* list1, Node* list2);