Function that changes the last value of an array

I need help with this assignment.

Write a function change that accepts an int array as the first parameter, and another int parameter for the length of that array and an int value as a third parameter. The function will store the integer value into the last element of the array. The original array SHOULD change. As an example, given the array int x = {5, 4, 9, 42};
The following call to your function change
change(x, 4, 14);
should change the value of the last element of the array to 14.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  #include <iostream>
using namespace std;
int change(int x[],int length,int *value);
int main()
{
	int i;
	int x[i];
	change(x,4,14);
}

int change(int x[],int length,int *value)
{
    x[length-1]=&value;
  	return x[];
}


I'm getting "invalid conversion from int to int*". I know my code is wrong but I have no idea where to go from here. Can anyone help?
You specified that the third parameter of 'change' is a pointer to int, but you're passing an int to it.

Line 13 is taking the address of a pointer, which is of type int** (pointer to pointer to int) and assigning it to an element of the array (an int).
Topic archived. No new replies allowed.