well I am trying to get array size to convert hex value to int value. but if I try to get size of array it returns every time 2. Actually .I dont understand. how to get array size, can you help me?
this is my code
unsigned long w;
void setup() {
Serial.begin(9600);
uint8_t * packet = read_packet();
Serial.println(sizeof(packet)); // PROMLEM IS HERE, IT RETURNS EVERYTIME "2"
for (int i = 0; i < 4; i++)
{
Serial.println(packet[i]); //if i print the packet array all elements are here
}
/*
for (byte i = 0; i < sizeof packet; i++) {
w = w + ((long)(packet[sizeof packet - (i + 1)]) << (i * 8));
}
*/
}
void loop() {
// put your main code here, to run repeatedly:
}
uint8_t *read_packet() {
static uint8_t buffer[4];
buffer[0] = 0x00;
buffer[1] = 0x32;
buffer[2] = 0x32;
buffer[3] = 0x32;
Serial.println(sizeof buffer);
return buffer;
}
if I print the packet array, all 4 elements are there 0,50,50,50. but size of array returns every time "2". even if I increase the array size.
maybe you can think why am I using pointers? because of my previous question answer is using this method. Read serial with header and end marker