I have a program based on a matrix and need various functions to be able to access this matrix and it's dimensions, which I get from the user. I've managed to do it by passing them as arguments to each separate function, but that doesn't seem efficient.
When I try to declare this:
int lin, col;
char matrix[lin][col];
I get an error: variable length array declaration not allowed at file scope. I'm guessing it's because at that point, I haven't asked the user for 'lin' and 'col'? My question is: is there a way to make my matrix of variable dimensions have global scope? Or a way to access this matrix and dimensions without passing them as arguments to various functions?