I have an array of strings which is char**
. It has 4 elements, and when I try to find the number of elements using sizeof(array) / sizeof(array[0])
, it always return 1 which leads to for loop unable to loop through all the elements in the char**
.
char** departmentList;
departmentList = malloc(sizeof(*departmentList)); // allocate
getAllDepartments(departmentList, recordsPtr[0], numOfDepartments);
printf("%d",sizeof(departmentList)/sizeof(departmentList[0])); // return 1
printf("%d",sizeof(departmentList[0])); // return 8
sizeof(departmentList)
yields 8 too.