I have an int array and I need to find the number of elements in it. I know it has something to do with sizeof but I\'m not sure how to use it exac
int
sizeof
I personally think that sizeof(a) / sizeof(*a) looks cleaner.
I also prefer to define it as a macro:
#define NUM(a) (sizeof(a) / sizeof(*a))
Then you can use it in for-loops, thusly:
for (i = 0; i < NUM(a); i++)