Use a char array instead of a string

I am using an RFID card reader and I've been messing around with the sample code. It uses a string to store the read card but I would rather use a char array.

  //content holds card's UIDs
  String content = "";
  //Reads UID

  if(mfrc522.uid.size != 4){
    return;
  }
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
    content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  //formats content
  
  content.toUpperCase();
  content.replace(" ", "");
  for (unsigned int i = 0; i < content.length(); i++) {
    rcv[i] = content[i];
  }
  Serial.println(rcv);

I would like to change 'content' to a char array to put less strain on my Arduino nano. Thanks!

uid is 4 bytes

Declare a character array that can hold the hex text representation of those 4 bytes; that is 8 nibbles so you need 8 plus 1 byte

char content[9];

If you want a seperator in between, you will have to make the array bigger.

Next you can use sprintf to fill the array with the required content

sprintf(buffer, "%02X%02X%02X%02X", mfrc522.uid.uidByte[0], mfrc522.uid.uidByte[1], mfrc522.uid.uidByte[2], mfrc522.uid.uidByte[3]);

2 indicates that the conversion will be at least two characters (sufficient for a byte), the 0 indicates to pd with a leading zero and the X does a uppercase hexadecimal text representation (x would do a lowercase).

I would like to change 'content' to a char array

here's a function that reads a complete line, terminated by a '\n', into a limited size char array

int
readString (
    char *s,
    int   maxChar )
{
    int  n = 0;

    Serial.print ("> ");
    do {
        if (Serial.available()) {
            int c    = Serial.read ();

            if ('\n' == c)
                break;

            s [n++] = c;
            if (maxChar == n)
                break;
        }
    } while (true);

    return n;
}