[SOLVED] Problem passing array pointer

mod edit (@harrisonhjones): Solution: See next post down


Trying to pass a pointer to an array but I only get the fist 4 elements in the array. I’m going crazy trying to debug this…

unsigned int DAIKIN_OFF[] = {9996, 25068, 3488, 1716, 444, 1288, 456, 408, 452, 416, 444, 424, 448};

void setup() {

void sendIR(unsigned int *IR_OUT) {
        // This returns correct "52"
        Particle.publish("DAIKIN_OFF", String(sizeof(DAIKIN_OFF), DEC));
        // This only returns "4"
        Particle.publish("IR_OUT", String(sizeof(IR_OUT), DEC));

void loop() {

That is the expected behaviour in C/C++.
Once you “cast” to an int* the size of the variable that pointer points to will be sizeof(int).

That’s why all standard functions that pass around arrays also pass the size, since it will be lost in translation :wink:


Thank you!