How can I pass a dynamic multidimensional array to a function?

后端 未结 9 2302
再見小時候
再見小時候 2020-12-19 05:48

How can I pass a multidimensional array to a function in C/C++ ?

The dimensions of array are not known at compile time

9条回答
  •  感情败类
    2020-12-19 06:18

    You can pass the pointer to initial memory location of your multi dimension array. you should also pass the size of array i.e. limit of each dimension.

    i.e

    int var [x][y][z];
    func (var, x, y, z);
    

    function definintion:

    void func (int*, int, int, int);
    

提交回复
热议问题