my requirement is to allocate a 2d char array in c language lets say of size 10 such that if I want to get its size later, I should get 10 as answer.
But I am stuck with 2 approaches both having some problems..
**Approach 1 **(Problem in getting actual size/number of rows)
char **arr = NULL;
arr = (char **)malloc(sizeof(char *) * 10);
int sz = sizeof(arr) / sizeof(arr[0]); //expected 10, but gives 8 (that is size of char ptr(8) / sizeof char (1))
Approach 2 (don't know malloc for this)
char *arr[] = {};
//malloc to allocate 10 rows
int sz = sizeof(arr) / sizeof(arr[0]); // gives 10 correctly