I am trying to pass a two dimensional array to a function and modify it. I understand that two dimensional arrays are automatically pass-by-reference parameters so that solves half of the problem. However, when I try to compile the code:
#include <cstdlib>
#include <iostream>
using namespace std;
int x, y;
void changeArray(int array[][y]){
array[1][1] = 5;
}
int main(int argc, char** argv) {
x = 5, y = 4;
int array[4][5];
changeArray(array);
return 0;
}
I get the error "array bound is not an integer constant". I have researched this problem online and only found solutions for when the array is declared with numbers as dimensions, not variables.