-2

I have provided the screenshot of the code and the error is also visible i don't understand the error and will appreciatle any kind of help.

  • 5
    Copy code to post, and don't attach an image of it. – Tony Tannous Jun 14 '20 at 09:26
  • 1
    Your merge expects an int* as it's first parameter while you are sending an int. The order of parameters passed to a function is important. – Tony Tannous Jun 14 '20 at 09:29
  • 2
    The order and number of arguments in the call to `merge(n1, n2, arr1, arr2)` doesn't seem to match the definition of `merge(int *arr1, int n1, int *arr2, int n2, int *ans)` in the screenshot. – anjsimmo Jun 14 '20 at 09:33

2 Answers2

0

You need to create a pointer to you array, and then give it to merge function. Or replace merge(*int arr1, int n1, *int arr2, int n2, *int ans) on links to array

Dies_Irae
  • 37
  • 4
0

merge is declared as void merge(int*, int, int*, int, int*). But in main you call it as

merge(n1, n2, arr1, arr2);

with int, int, int*, int* (5th parameter is missing). You need to allocate some memory for the parameter ans. Presumably something like

auto arrAns = new int[n1 + n2];

(don't forget to delete[] it at the end!) and pass them in the correct order:

merge(arr1, n1, arr2, n2, arrAns);

Finally some notes:

Lukas-T
  • 11,133
  • 3
  • 20
  • 30