I have the following:
typedef unsigned char BYTE;
size_t arrMod (BYTE ARR[3])
{
ARR[1] = 255;
return sizeof(ARR);
}
int main()
{
BYTE arr[3];
size_t s = arrMod(arr);
fprintf(stdout,
"Size = %i\nARR[0] = %i\nARR[1] = %i\nARR[2] = %i",
s, arr[0], arr[1], arr[2]);
return 1;
}
And the output is:
Size = 12
ARR[0] = 0
ARR[1] = 255
ARR[2] = 0
I know that i can't give it sizeof(ARR)
to get the wished 3 bytes, because the array decays into a pointer. I am basically receiving the pointer size. How can i get arr's size (3) as a return value from the function?