X
xtheunknown0
I want to be able to pass a pointer to a 2D array of chars to a function
such that the function can access the array like this:
grid[j] = 'a';
I can do a similar thing with 1D arrays (of any data type), but I'm lost
with 2D arrays. So far, I've written a program that doesn't compile. Could
you please help?
#include <stdio.h>
#define MAX 500
void foo(char *grid[]) {
}
int main(void) {
char grid[MAX][MAX];
foo(grid);
return 0;
}
TIA,
xtheunknown0
such that the function can access the array like this:
grid[j] = 'a';
I can do a similar thing with 1D arrays (of any data type), but I'm lost
with 2D arrays. So far, I've written a program that doesn't compile. Could
you please help?
#include <stdio.h>
#define MAX 500
void foo(char *grid[]) {
}
int main(void) {
char grid[MAX][MAX];
foo(grid);
return 0;
}
TIA,
xtheunknown0