I want to copy some part of data into source_mac
This is my code:
uint8_t *data
uint8_t *source_mac
memcpy(&source_mac, &data[6], 6);
So I want to copy 6 bytes from data, starting with the 6th byte in data, into source_mac... What am I doing wrong?
&source_macthis is the address of the pointer variable, not where it points to. Usesource_macor&source_mac[0]memcpycall tries to copy 6 bytes from some random location (&data[6]) to wherever thesource_macvariable is located (which depends scope, which is unclear from your incomplete code example). Even ifdatawas properly initialized, passing&source_mactomemcpyoverwrites thesource_macvariable, not what it (should) point to.