Merge Sorted LL

in the above code, it is showing the error of code dumped, can’t understand where the mistake happens, please help to spot the problem.

the problem may be in main() function because the class node and print function is copied from correct code, and I had tried the code by commenting the merge function then also getting same core dumped error.

Now no segmentation fault. But dry run and check your code as it is not giving correct result.

thnx bro, but now while printing LL after merge it is printing only 1st and last node only, please solve this also

correct approach

node* merge(node *a, node *b) {
	if (a == NULL) {
		return b;
	}
	else if (b == NULL) {
		return a;
	}
	node *c = NULL;
	if (a->data < b->data) {
		c = a;
		c->next = merge(a->next, b);
	}
	else {
		c = b;
		c->next = merge(a, b->next);
	}
	return c;
}

https://ide.codingblocks.com/s/262906 , tumhare method s bhi sirf test case 3 hi successful aa rha h aur isme 5 test cases h

Refer this and check.