sizeof() an Array - Bug or Feature

In a sketch I needed a two variable array so I used float[1]. I was stumped for way to long when the radio library was only sending one value. The call is radio.send(&variable, sizeof(variable)).

Then i did a serial print of size of the two dimension array of float. It returned 4. Which is the size of a single float data type. I have to dimension one more than i need to get the proper amount of bytes to get the proper values in the radio code.

I looked at the examples in the reference - seems they are using for loops with initial values of zero and >size of for the terminator. With the sizeof used this way - it will work, but not with the radio library code.

Just curious

float[1] creates a one element array.

I think you are confusing declaring and accessing the array. In the declaration, you need to specify how many elements your array will have. When you’re accessing them, the array indexes will run from 0 to the size of your array -1. So a three integer array is declared and used like this:

int MyArray[3];
for(int lp=0;lp<3;lp++)
  MyArray[lp]=66;

I stand corrected -