The problem is that if you cannot pass an array to a function. When you do so, the name of the array "decays" to a pointer to its first element. That means you no longer know the size of that array, as you can only pass around a pointer to an element in that array. So you have to pass it a size, so the function receiving the "array" knows how long it is.
e.g.
//the below declaration is even the same as e.g.
//void foo(unsigned char array[4], size_t length)
//the array notation doesn't really apply to a function argument list
//it'll mean a pointer anyhow.
void foo(unsigned char *array, size_t length)
{
size_t i;
for(i = 0; i < length ; i++) {
printf("%02X ", array[i]);
}
}
Or in the case where you pass in a pointer one element past the end of the array:
void bar(unsigned char *array, unsigned char *end)
{
while(array != end) {
printf("%02X ", *array);
array++;
}
}
And you call it like
unsigned char data[] = {1,2,3,4};
foo(data,sizeof data); //same as foo(&data[0], siseof data);
bar(data, data + 4); //same as bar(&data[0], &data[4]);