How can I easily output all elements of an array in a snprintf function?
// this is the way for Serial output
int temperatureNumDevices = 5;
for (int i=0; i<temperatureNumDevices; i++) {
Serial.print(temperatureArrayChar[i]);
}
and I can this do with snprintf by defining every single array element in sprintf
snprintf(buffer, size, "%s,%s,%s,%s,%s", temperatureArrayChar[0], temperatureArrayChar[1], temperatureArrayChar[2], temperatureArrayChar[3], temperatureArrayChar[4]);
But I want do something like
snprintf(buffer, size, "%s,[x temperatureNumDevices]", temperatureArrayChar[0 to temperatureNumDevices]);
to have the code flexible in case temperatureNumDevices is changing. Can I do this in snprintf directly or do I have to make some helper variables with the values of the array?