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

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?

Use pointers. This should clear things up:

1 Like