Pages: [1]   Go Down
Author Topic: handing over byte array to function via pointer  (Read 769 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I try to manipulate a (non global) byte array by using another function.
As far as I understood I can't hand over and return the array. I have to do it via a pointer.

So I tried it based on an example out of this thread: http://arduino.cc/forum/index.php/topic,42934.0.html

My code:
Code:
void download ()
{
byte buf[32];
rgbTo8Bit(&buf);
}

void rgbTo8Bit (byte *pbuf){
pbuf[0]=pbuf[1]/2 //just dummy code
}

The error I get when compiling is:
error: no matching function for call to 'rgbTo8Bit(byte (*)[32])'
note: candidates are: void rgbTo8Bit(byte*)

I don't get what is wrong. Can't I reference to an array like this?

Thanks
Robert
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 152
Posts: 6176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you do not use an array index, it is already a pointer.
Code:
rgbTo8Bit(buf);
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot for the swift and workling anser.  smiley

Robert
Logged

Pages: [1]   Go Up
Jump to: