How to pass a two-dimensional array to a function in C?

前端 未结 3 1346
时光说笑
时光说笑 2021-01-15 07:59

My function prototype is

int** rotate(int **arr, int row, int col, int fl);

where arr is the two dimensional array, row<

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-15 08:22

    From the example, I assume that you are using a static definition of arr.

    The Pointer to pointer is not the same as a 2D array.

    Change

    int** rotate(int **arr, int row, int col, int fl);
    

    to

    int** rotate(int arr[][20], int row, int col, int fl);
    

    Note that the no of columns will have to be defined before compilation.

提交回复
热议问题