quite simply, you
cannot get the size of a dynaimcally allocated array using
sizeof(). It will always return 4 (or whatever size a pointer is on the platform). To get the size at runtime, you either need to store it in a separate variable (like num_elements) or use static arrays, but I recommend using a separate variable, because it gives you more flexibility.
But it all depends on what you're using the array for. If it can be static without wasting too much memory and doesn't need to grow dynamically, then use a static array, like this:
code:
float static_array[20]; // 20 fixed elements
sizeof(static_array) will give you 80 (eighty bytes), so yuo need to divide by the size of one element to get the total number of elements in the array. It looks like this:
code:
num_static_elements = sizeof(static_array) / sizeof(static_array[0]);
Hope this answers your question