Skip to main content
LimoGr
Associate II
March 22, 2023
Solved

I am not able to copy a uint8_t to uint8_t*

  • March 22, 2023
  • 1 reply
  • 1973 views

Hi! I don't know if this is the right place to ask this question and it may seem stupid but I am a beginner and have been trying to resolve this for one day.

I am receiving one byte of data through UART to Rxdata, I want to copy this one byte to a 10 bytes buffer. I used this function:

uint8_t Rxdata[1];

uint8_t* Buffer[10];

int head=0;

memcpy(Buffer[head],Rxdata,1);

head++;

If someone can help me with this I would be grateful. And if you have also good explanation of variable types (It is still not very clear in my head)

Thank you!

This topic has been closed for replies.
Best answer by Tesla DeLorean

memcpy(&Buffer[head],Rxdata,1);

​or

Buffer[head] = *Rxdata;

o​r

Buffer[head] = Rxdata[0];

1 reply

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
March 22, 2023

memcpy(&Buffer[head],Rxdata,1);

​or

Buffer[head] = *Rxdata;

o​r

Buffer[head] = Rxdata[0];

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
LimoGr
LimoGrAuthor
Associate II
March 22, 2023

Thank you!