Passing multidimensional arrays [solved]
How do you pass a variable length multidimensional array to a function in C? Take the code snippet below as an example. Void foo(int **); main() { int a; scanf("%d",&a); int ar[a][a]; foo(ar); printf("%d",ar[0][0]); } Void foo(int **a) { a[0][0]=12; } in that snippet, I wanted to pass a VLA to the function foo which will then set element [0][0]. Then I wanted to print that change from main. But my function prototype is not correct. It will be easier if the second index was known before hand like ar[][5], but in this case, neither of the index is known at compile time as it depends on user input. I tried declaring the array as global but that was worse as it was declared before it's index. A quick solution would be to define the length of the array, but I want the user to enter the length of the array instead of tampering with the source code to change the defined value. So help!!