xxxxxxxxxx
char buf[256]; // Watch out for buffer overflows!
sprintf(buf, "Value of Pi = %f", M_PI);
// Declaration:
int sprintf(char *str, const char *format, )
sends formatted output to a string pointed to, by str
xxxxxxxxxx
#include <stdio.h>
int main() {
char str[32];
int i = 123;
double d = 4.56;
sprintf(str, "int: %d, double: %f", i, d); // str will be "int: 123, double: 4.560000"
printf("%s\n", str);
}
xxxxxxxxxx
char myConcatenation[80];
char myCharArray[16]="A variable name";
int myInt=5;
sprintf(myConcatenation,"%s = %i",myCharArray,myInt);
Serial.println(myConcatenation);