How to get size of 2D array pointed by a double pointer?

前端 未结 2 1720
你的背包
你的背包 2020-12-10 07:32

I am trying to get the number of rows and columns of a 2D Array from a double pointer pointed to the array.

#include 
#include 

        
2条回答
  •  臣服心动
    2020-12-10 08:06

    void get_details(int **a)
    {
     int row =  ???     // how get no. of rows
     int column = ???  //  how get no. of columns
     printf("\n\n%d - %d", row,column);
    }
    

    I'm afraid you can't, as all you will get is the size of the pointer.

    You need to pass the size of the array. Change your signature to:

    void get_details(int **a, int ROW, int COL)
    

提交回复
热议问题