array as parameter of a function

后端 未结 3 837
旧巷少年郎
旧巷少年郎 2021-01-24 05:09

There is a array of structures.

    static field fields[xsize][ysize];

I want to change it in function

    void MoveLeft(pacma         


        
3条回答
  •  醉酒成梦
    2021-01-24 05:34

    I guess the error is the following: two dimension array fields[xsize][ysize] is fixed size array (xsize/ysize are defines or consts) and in memory this is not look like field**, cause it's pointer to pointer to field, while fields[xsize][ysize] internally just one dimension fixed size array, where compiler handle double indexing for you.

    So what you need is just define fields as field** and allocate it dynamically.

    See picture for more explanation: enter image description here

提交回复
热议问题