Need help passing a 2dArray of a Structure by reference!

I'm having trouble passing a 2D array of a structure and editing it in a function. I just typed up a quick little example code to maybe give anybody an idea of what I am trying to do. Every time I fix one error another one occurs. Any help would be highly appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  #include <string.h>
#include <stdio.h>

struct map
{
    int sand;
    int treasure;
};
//Function setup.

void editMap(struct map* treasure_map[3][3]);

int main()
{
    struct map treasure_map[3][3];

    editMap(&treasure_map);
    return 0;
}

void editMap(struct map* treasure_map[3][3]){
    treasure_map[0][0].sand = 15;
    printf("%d sand" treasure_map[0][0].sand);
}
It would help you in the long run, if you would describe the trouble and error in more detail.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <string.h>
#include <stdio.h>

struct Map
{
    int sand;
    int treasure;
};

void editMap(struct Map treasure_map[][3], int rows );

int main()
{
    struct Map treasure_map[3][3];

    editMap( treasure_map, 3 );

    printf( "%d sand\n", treasure_map[0][1].sand );
    return 0;
}

void editMap( struct Map treasure_map[][3], int rows )
{
  if ( 0 < rows )
    treasure_map[0][1].sand = 15;
}

Topic archived. No new replies allowed.