How can I make a 2-D array in C using user inputs

I tried to make a 2-D array given the numbers of rows and columns as the user input.

int main(void)
   int nx, ny;
   scanf_s("%d", &nx);
   scanf_s("%d", &ny);
   int array[nx][ny];
   return 0;

But VSC is telling me that I must have constants in the parenthesis [].

Is there any way I can convert 'nx' and 'ny' as constant?

Or is there any other way to declare 2-D or N-D arrays without converting their dtype?

Read more here:

Content Attribution

This content was originally published by patha at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: