Lets say I have a 2d array:
int array[3][3];
with
000
111
222
and I want to remove 000
.
I wrote a function:
void remove(int (*array)[3], int index, int array_length)
{
int i;
for(i = index; i < array_length - 1; i++)
{
array[i] = array[i + 1];
}
}
which receives pointer
to the first element of the 2d array, index
which I want to remove and a length
of the array.
In the for loop, I move array at the position index to the next element.
But I receive this error message:
error: assignment to expression with array type
array[i] = array[i + 1];
Why?
How can I remove element and get the 2d array without array at the index? Should I maybe make new 2d array and return it instead of passing pointer of 2d array to the function?