I am stuck in a conversion / definition of a function parameter and would very much appreciate some help. I am sure it’s an easy one for any experienced c/c++ guy, but not for me, not right now.
Problem:
creating the right parameter to use with myCommmand(uint8 *pAddr), which will execute send(pAddr, 6), which will use those parameters to loop the following 6 times:
write(reinterpret_cast<unsigned char*>(pAddr)[i]);
my trouble is, that pAddr has to point to an array of 6 bytes, which i most preferably would like to define as unsigned byte values (0-255) or as hex 00-FF.
Restrictions
Functions shall not be changed. It is just about creating the parameters.
My attempts:
uint8 Addr[] = {00,22,122,205,16,04};
uint8 *pAddr = &Addr;
but this results in error C2440 (can’t convert uint(*)[6] to uint8 *).
Desired solution
I would like to know a good, wellformed way to create this Addr-array or stream, or object to pass on to my functions, by writing their byte or hex values into my code – like in my attempt. I can use boost-libraries. Thanks to all helping me out with this!
Have you tried
?
Note: Do not use
0prefix! It means the number is in octal, so010means8in dec.