1. 2d Array of structs(Help)

Hi. So I'm not sure why my program crashes when I run this code. Any help would be appreciated. Thanks

Code:
```typedef struct
{
char token;

}Grid;
void initialize_grid(Grid *grid[][7]);
void print_grid(Grid *grid[][7]);```
definitions:
[code]

void initialize_grid(Grid *grid[][7])
{
for (int y = 0; y < 6; y++)
{
for (int x = 0; x < 7; x++)
grid[y][x]->token = '0';
}
}

void print_grid(Grid *grid[][7])
{
for (int y = 0; y < 6; y++)
{
for (int x = 0; x < 7; x++)
printf(" %c", grid[y][x]->token);
printf("\n");
}
}

[code/]

main:
Code:
```int main(void)
{
Grid grid[6][7];
initialize_grid(&grid);
print_grid(&grid);

}```

2. I am puzzled as to why you would call a structure consisting of a single char a "grid". Perhaps you had this in mind instead:
Code:
```typedef struct
{
char token[6][7];
} Grid;```
Now, you can simplify your Grid functions:
Code:
```void initialize_grid(Grid *grid)
{
for (int y = 0; y < 6; y++)
{
for (int x = 0; x < 7; x++)
grid->token[y][x] = '0';
}
}

void print_grid(Grid *grid)
{
for (int y = 0; y < 6; y++)
{
for (int x = 0; x < 7; x++)
printf(" %c", grid->token[y][x]);
printf("\n");
}
}```
and then your main function would work almost as-is:
Code:
```int main(void)
{
Grid grid;
initialize_grid(&grid);
print_grid(&grid);
}```

3. As laserlight said, your code doesn't really make sense as is. There are three possibilities.

1. laserlight's guess (and without your feedback, all we can do is guess!) is to take you at your word that Grid is a good name for the struct and put the whole grid of chars in the struct.

2. Alternatively, you could get rid of the struct altogether and just use a 2D array of chars: char grid[ROWS][COLS]

3. Finally, perhaps the struct was misnamed and should have been called something like Position. The idea here is that it will eventually have more than just a char in it. That code might look something like the following, which is similar to your original code. (The "\033..." part is for setting colors. This may not work on your system, in which case just remove those parts.)
Code:
```#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define ROWS 6
#define COLS 7

typedef struct {
char token;
int  weight;
} Position;

void initialize_grid(Position grid[][COLS]) {
for (int r = 0; r < ROWS; r++)
for (int c = 0; c < COLS; c++) {
grid[r][c].token = '0';
grid[r][c].weight = rand() % 2;  // random "weight" or 0 or 1
}
}

void print_grid(Position grid[][COLS]) {
for (int r = 0; r < ROWS; r++) {
for (int c = 0; c < COLS; c++) {
if (grid[r][c].weight > 0) printf("\033[34m"); // 34 is blue
printf(" %c", grid[r][c].token);
printf("\033[m"); // back to default color
}
printf("\n");
}
}

int main(void) {
srand((unsigned)time(NULL));
Position grid[ROWS][COLS];
initialize_grid(grid);
print_grid(grid);
return 0;
}```