In C++, how to setup a char grid2d[x][y] with variables

In C++, how to setup a char grid2d[x][y] with variables
0

#1

char grid2d[x][y] doesn’t work because it is expecting constants (or defines for each of the indices].
#define won’t work because x and y are not known until runtime, although once set, they never change.

The interfaces I’m passed are not changing, so I need to use grid2d in a function call.

Any ideas how I can get this to work?


#2

Use pointers. This should clear things up: