Hi,
From other posts on this forum I've learnt that I should be able to use sizeof() to calculate the size of an array.
This simple sketch shows my problem....
#include "Arduino.h"
const int arraySize = 6;
byte _status[arraySize];
void setup()
{
Serial.begin(115200);
// populate all six elements of the array with some random test data....
_status[0]=1;
_status[1]=2;
_status[2]=3;
_status[3]=4;
_status[4]=5;
_status[5]=6;
showArrayByte(_status);
}
void loop()
{
}
void showArrayByte (byte inArray[])
{
// Work out the number of items in the array
int len= sizeof(inArray) / sizeof(inArray[0]);
Serial.print("len=<");Serial.print(len);Serial.println(">");
int a=sizeof(inArray);
int b=sizeof(inArray[0]);
Serial.print("a=<");Serial.print(a);Serial.println(">");
Serial.print("b=<");Serial.print(b);Serial.println(">");
for (int i=0;i<=len ;i++ )
{
Serial.print("index=<");Serial.print(i);Serial.print(">, value=<");Serial.print(inArray[i],DEC);Serial.println(">");
}
}
I'm expecting the length to be 6 and the whole array to be displayed, but this is what I'm getting....
len=<2>
a=<2>
b=<1>
index=<0>, value=<1>
index=<1>, value=<2>
index=<2>, value=<3>
I expect I'm doing something foolish, can someone please enlighten me?
Thanks