How to get the number of elements in the float table in C?

advertisements

This question already has an answer here:

  • How do I determine the size of my array in C? 20 answers

I'm trying to get the number of floats in the following array:

float coins[] = {0.25, 0.10, 0.05};
printf("%i", sizeof(coins));

I get 12.

I am trying to get 3.

What am I missing here?


you can get the number of elements in array by,

array_size/single_array_element_size

i.e.

sizeof(coins)/sizeof(float)