Passing an array to a function and using sizeof in Arduino

Viewed 13963

I'm an Arduino padawan learner. I want to pass a byte array to a function and get the size of the array.

byte data[] = {
    B00000000,
    B00000001,
    B00000011,
    B00000111
};

Serial.println(sizeof(data)); // ----------------------> displays 4

When I pass it to a function sizeof returns 2. How can I get it to return 4 also in the function?

writeData(data);

void writeData(byte data[]) {
    Serial.println(sizeof(data)); // -------------------> displays 2
}
1 Answers
Related