I am solving problems on online judge like Leetcode and I wonder if it' possible to get size of a 2d array given int**A. Consider the function,
int help(int** A){
int rows = sizeof(A)/sizeof(A[0]);
int columns = sizeof(A[0])/sizeof(A[0][0]);
}
But I am not getting the correct values of rows and columns. Is there a way to get sizes of a 2d array if I only have int** A. Same question for char** A. I know that the question is poorly framed but I am a beginner in C. Thank you.
There's nothing in the allocated memory that indicates where it starts and ends. For 2D arrays, there's not even a guarantee the memory is contiguous.
**A
does not contain any data about itself - all of the info about the array must be kept track of by the programmer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.