That will work. There's a simpler, and more conventional way to do it:
void loop()
{
byte data[2];
getdat(data);
}
void getdat(byte pdata[])
{
pdata[0] = 'a';
pdata[1] = 'b';
}
Either way, the same address gets passed to getdata(). In the function declaration for getdat(), I would use 'byte pdata[]' rather than 'byte *pdata' because I will be referencing pdata as an array rather than a character pointer. Once again, the way you did it was equivalent, but saying it's an array makes it a tiny bit more self-documenting.
By the way, if you wanted to change the value of two variables in getdat(), rather than using an array, here's one way to do it:
void loop()
{
byte data1;
byte data2;
getdat(&data1,&data2);
}
void getdat(byte *d1,byte *d2)
{
*d1 = 'a';
*d2 = 'b';
}
Personally, I'd use an array, as you did.
Regards,
-Mike