How do we get the number of elements in an arraywithout using sizeof
. In any case sizeof does not get me the correct number of elemnts so I want to implement my self without using sizeof
.
I tried to run using sizeof
and it doesn't print the correct number of elements in an array.
int n = sizeof(arr) / sizeof(arr[0]);
for (int i = 0; i < n; i++){
printf("%s\n", arr[i]);
}
// to check if the noof elts in the arr is correct
printf("%d\n", n);