I cannot create a 2D array from 2 variables (eg int arr[i][j] not allowed) so how would I create a dynamically sized 2D array?
The dimensions of the array are only known at runtime in my program. The array is to represent a grid. How would I code this in C?
int arr[i][j];. (If you don't have a C99 compiler, it's time to get one.) With that said, how do you plan to access the array? You can either be hoping to usearr[i][j]to access an element, or you can be prepared to use a calculation likearr[i*n+j]to access it. The memory allocation patterns required are quite different for the two cases.