Converting an array to a string

Ive had a look at google but so far the things I have tied don't seem to be working.

I'm struggling to convert a char array into a String. Any help with this would be appreciated.

I have managed to build the String using a for loop but I wondered if there was a more efficient way to build it.

Bellow is code I am trying...

char *addCard[] {"1", "A", "99999999", "000", " ", "0000000000000000", "0000000000000000", "0000000000000000", "0000000000000000", "N", "N", "N", "####", "E", "000", "N", "N", "230817", "000000000000"};

void setup() 
{
  Serial.begin(1200);
}
void loop() 
{
  String myString = *addCard;
  Serial.print("String - ");
  Serial.println(myString);
  delay(1000);
}

rich_330:
I’m struggling to convert a char array into a String. Any help with this would be appreciated.

I’ll leave it to others to admonish you about the evils of the String class and to ask why you’re trying to do such a thing – as they surely will. But, here ya go (compiles and tested on an Uno):

const char * const addCard[] {"1", "A", "99999999", "000", " ", "0000000000000000", "0000000000000000", "0000000000000000", "0000000000000000", "N", "N", "N", "####", "E", "000", "N", "N", "230817", "000000000000"};
constexpr uint8_t numStrings = sizeof(addCard) / sizeof(addCard[0]);

void setup()
{
  String myString = "";
  Serial.begin(115200);
  delay(1000);

  for (uint8_t i = 0; i < numStrings; i++) {
    myString += addCard[i];
  }

  Serial.print("String - ");
  Serial.println(myString);
}
void loop() {
}

Thanks for the reply and help! :slight_smile: