#include <stdarg.h>
#define PRETTY_BUFF 80
void setup() {
Serial.begin(115200);
pretty("This is the %dth test of %d \n", 5, 10);
}
int pretty(char *str, ...) {
char buff[PRETTY_BUFF];
va_list args;
va_start(args, str);
vsnprintf(buff, sizeof(buff), str, args);
int res = Serial.print(buff);
va_end(args);
return res;
}
#include <stdarg.h>
#define PRETTY_BUFF 80
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
prettyP(F("This string was %d chars long"), sizeof(test));
}
int prettyP(const __FlashStringHelper *str, ...) {
char buff[PRETTY_BUFF];
va_list args;
va_start(args, str);
vsnprintf_P(buff, sizeof(buff), (const char *)str, args);
va_end(args);
return Serial.print(buff);
}
This secion of the original book has been removed in the second edition.
However the original content has been moved to a blog post along with the relevant code still available to copy and paste.