Merge Sorted Linked Lists

I am getting wrong answer on submission, my code is https://ide.codingblocks.com/s/306611

you need to make some changes in the merge function, if head1->data is less than head2->data, just put head = head1 and head->next = merge(head1->next, head2) and similar changes would happen in else you dont need to write the while loop etc
Corrected Code