Converting String to Hex Help

I am currently receiving a string from a Xamarin forms app that is sent as "0A0100004006C03F";
I want represent this as an array of bytes such as msg[8] = {0x0A,0x01,00,00,40,06,C0,3F};

Thanks!

Maybe (untested)

sscanf(s, "%2X%2X%2X%2X%2X%2X%2X%2X", msg[7], msg[6], msg[5], msg[4], msg[3], msg[2], msg[1], msg[0]);

Do you mean convert the input string to an array of binary values in the computer memory, or to a source code statement?

as you have only 8 bytes it fits in an unsigned long long.

if you are happy with an inverse representation in memory (little endian) then strtoull() could help

try this

(I don't think strtoull() is available on small AVR though)

char message[] = "0A0100004006C03F";
uint64_t messageValue;

void setup() {
  Serial.begin(115200);
  messageValue = strtoull(message, nullptr, 16 ); // https://cplusplus.com/reference/cstdlib/strtoull/

  Serial.print("0x");
  Serial.println(messageValue, HEX);

  Serial.println("bytes are:");

  byte *ptr = (byte *) &messageValue;

  // print what we got in memory, reverse order because of little endian representation
  for (int i = (sizeof messageValue) - 1 ; i >= 0; --i) {
    Serial.print("0x");
    if (ptr[i] < 0x10) Serial.write('0');
    Serial.println(ptr[i], HEX);
  }
}

void loop() {}