You basically have three choices, switch to two matrices, put the dimensions in the struct, or have create() take an array of struct:
Two arrays:
void create(int a[9][9])
{
a[0][2] = 4;
}
int main()
{
int p[9][9];
int s[9][9];
create(s);
}
-- or -- put the dimensions in the struct:
struct grid{
int p[9][9];
int s[9][9];
};
void create(int a[9][9])
{
a[0][2] = 4;
}
int main()
{
struct grid a;
create(a.s);
}
-- or -- Pass an array of struct
struct grid{
int p;
int s;
};
void create(struct grid[9][9] * a)
{
(*a)[0][2].s = 4;
}
int main()
{
struct grid a[9][9];
create(&a);
}
You cannot cherry pick elements out of an array or matrix of structs
int,int[][9]are two different types. You can not intermix. To access the members of the array, you need to use[]operator.