I am creating a two-dimensional array in C as follows:
int array1[] = {1,2,3,4,5,6,7,8,9,10};
int array2[] = {11,12,13,14,15};
int* array3[2] = {array1,array2};
and now I want to get the size of both dimensions. For the first dimension I get the correct result of 2 if I use the following code:
int array3_x = sizeof(array3)/sizeof(*array3); // array3_x = 2
but I am not able to get the size of the other dimension. So far I have tried the following:
for (int i = 0; i < array3_x; ++i) {
array3_y[i] = sizeof(array3[i])/sizeof(*array3[i]);
}
I always get a result of 1. Is there a way to get the correct sizes of 10 and 5?