How can i covert two char into string?
I have matrix keyboard,from keyboard i get single char (ex,1,2,A) but i want to get it like A1,A2.B1.two charecters as input.because i can't control my 12th number LED by keyboard
char text[3];
void setup() {
Serial.begin(250000);
text[0] = 'A';
text[1] = '1';
Serial.print(F("combined chars \""));
Serial.print(text);
Serial.println(F("\""));
}
void loop() {}
combined chars "A1"
It might help understand the example if you know that declaring the array as a global initialises each of its elements to zero. Thus when elements 0 and 1 are set to 'A' and '1' respectively the zero is still in element 2 which fulfills the requirement that a C style string, which is an array of chars, is terminated with a zero
char text[3];
void setup() {
Serial.begin(250000);
text[0] = 'A';
text[1] = '1';
text[2] = 0;
Serial.print(F("combined chars \""));
Serial.print(text);
Serial.println(F("\""));
}
void loop() {}
Even better thanks