how to find 2d array size in c++

后端 未结 9 838
余生分开走
余生分开走 2020-12-23 12:14

How do I find the size of a 2D array in C++? Is there any predefined function like sizeof to determine the size of the array?

Also, can anyone tell me h

9条回答
  •  青春惊慌失措
    2020-12-23 12:48

    int arr[5][4];

    For the row subscript(4 raise to 2, include cmath to use pow):

    sizeof(arr1)/pow(4,2)   
    

    Column subscript:

    sizeof(*arr1)/4
    

    4 means 4 bytes, size of int.

提交回复
热议问题