concat a char or a String

Hello
I have a char array that I need to get together to form a String.Is this possible?
I just have 3 char arrays
char[0] which holds an "O"
char[1] which holds a "K"
char[2] wich holds a "1"

I would like to my final String be "OK1" for the use on if cicles
Can someone give me a tip?

I just have 3 char arrays
char[0] which holds an "O"
char[1] which holds a "K"
char[2] wich holds a "1"

That is not 3 char arrays. That is one char array, with three elements.

Make the array one element larger, and add

char[3] = '\0'; // NULL terminate the array

Then, you will have a string, which is MUCH better than a String.

ok I add that but that does not fix my problem I still need to concat it right?

ok I add that but that does not fix my problem I still need to concat it right?

No.

You do need to tell us what your problem is, and show some code, though.

I have this if cicle:

void retira_numero_sms()
{
int l = 47;
for (int j=0;j<=12;j++){
numero[j] = sms_array[l];
l++;
  }
Serial.println("Numero de SMS Retirado");
for(int i = 0; i<= 12; i++){
  Serial.print(numero[i],BYTE);
  }
}

I need to char numero get all elements in just one String to display it

here is the entire code

char numero[12];
char corpo[2];
char sms_array[120];
int i = 0 ;



void setup()  
{
  Serial.begin(9600);
  Serial.println("IInicia Leitura Modem");
  Serial1.begin(9600);
  delay(500);
  Serial1.println("AT+CMGF=1\r\n");  // SetSerial1 mode to text (vs pdu)
  delay(500);
  Serial1.print("AT+CMGR=1");  


}



void loop()                     // run over and over again
{
carrega_array_dados();
retira_numero_sms();
retira_corpo_sms();


}


void carrega_array_dados()
{
Serial1.println("\r\n"); // Read SMS in position 1 or 2
delay(500);
while (Serial1.available() > 0 ) {
sms_array[i] = Serial1.read();
//delay(30);
i++;
//delay(100);
} 
}

//________________________
void retira_numero_sms()
{
int l = 47;
for (int j=0;j<=12;j++){
numero[j] = sms_array[l];
l++;
  }
Serial.println("Numero de SMS Retirado");
for(int i = 0; i<= 12; i++){
  Serial.print(numero[i],BYTE);
  }
}
  
  
//________________________
void retira_corpo_sms(){
int l = 87;
for( int i = 0;i<= 2; i++){
  corpo[i] = sms_array[l];
  l++;
   Serial.print(corpo[i],BYTE);
}
}

First, you need to understand that string (a NULL terminated array of chars) and String are two completely different things. Which is it you want?

If you are smart, you want a string, which means that you simply need to NULL terminate the array that you already have, and are populating. The numero array, though, is not big enough to hold the NULL, so you need to make it one element bigger. On a second reading of your code, I see that you are currently putting 13 values in your 12 element array, so you need to make it 2 larger.

hello PaulS
Thanks it finaly works fine
All I need was add the end of string on each array and now I can print it

On a second reading of your code, I see that you are currently putting 13 values in your 12 element array, so you need to make it 2 larger.

I think you are wrong since array[0] position is also included so my size is fine.All I need was add an extra element to put the end of string
thanks very much for your help, it really save me lots of time.

I think you are wrong since array[0] position is also included so my size is fine.

for (int j=0;j<=12;j++){
numero[j] = sms_array[l];
l++;
  }

This loop will write into the numero array, at positions 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, and 12. That's 13 values.

char numero[12];

The array is sized to hold 12.

I'm pretty sure that 13 is more than 12.