Can I not use more than one buffer with the sprintf() function? Here is a program that shows that the second buffer corrupts the first buffer... I am trying to understand what is causing this...
char buff1[3];
char buff2[3];
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
sprintf(buff1,"%d:%d",1,2); // 1:2
Serial.print("buff1>");
Serial.print(buff1);
Serial.println("<");
sprintf(buff2,"%d:%d",3,4); // 3:4
Serial.print("buff2>");
Serial.print(buff2);
Serial.println("<");
Serial.print("buff1>");
Serial.print(buff1);
Serial.println("<");
}
void loop() {
// put your main code here, to run repeatedly:
}
The output with this program is:
buff1>1:2<
buff2>3:4<
buff1><
Why did buff1 change when we assigned buff2?