I am trying to create an array with the following requirements:
- internal linkage (static global)
- size only known at runtime
- elements accessed using the
[][]
syntax - stored on the heap
I have been using the following code to create a VLA which meets almost of my requirements, but this array is limited to the current scope rather than having internal linkage.
int (*array_name)[columns] = malloc( sizeof(int[rows][columns]) );
Is there any way to create an array which meets all of my needs?
Edit - "static global" is an incorrect term for this type of variable scope, "internal linkage" is correct. Please look at the comments to this question for an explanation.