C++ Pass a reference to an array to function

Viewed 19055

Given to functions void main() and void hello(byte* a[4]). Main function has an array of four bytes. The array's reference needs to be passed to the function hello for manipulation. I would expect the right syntax to be:

void hello(byte* a[4]){
 // Manipulate array
 a[0] = a[0]+1;
}

void main(){
 byte stuff[4] = {0,0,0,0};
 hello(&stuff);
 // hopefully stuff is now equal {1,0,0,0}
}

Alternatively I see others using this form of decaration:

void hello(byte (&a)[4])

Is this the right way to do it?

3 Answers
Related