There is a array of structures.
static field fields[xsize][ysize];
I want to change it in function
void MoveLeft(pacman *Pacman, field **fields,int **play)
But when I send it like this
MoveLeft(&Pacman,fields,play);
I’ve got an error.
field – structure
typedef struct
{
blossom blossoms;
wall walls;
}field;
where blossom & wall – another structures
Although arrays and pointers are somewhat interchangeable in C, they’re not exactly the same. In particular, an array of arrays and an array of pointers are laid out differently in memory.
Here’s a way to make an array of pointers which refers to the same data as your existing array of arrays:
Then a pointer to that
field_rowsarray can be passed toMoveLeft:Another solution might be to change the declaration of
MoveLeftinstead, to take a pointer to array of arrays: