String class


String::format, format, String.format

Since 0.4.6:

Particle.publish("startup", String::format("frobnicator started at %s", Time.timeStr().c_str()));

int a = 123;
Particle.publish("startup", String::format("{\"a\":%d}", a);

static String format(const char* format, ...);

Provides printf-style formatting for strings.

Sprintf-style formatting does not support 64-bit integers, such as %lld, %llu or Microsoft-style %I64d or %I64u.

This method returns a temporary String object. Use care because the temporary object is deleted after return.

// DO NOT DO THIS: s points to a deleted object
const char *s = String::format("testing %d", a); 

// This is safe
String s = String::format("testing %d", a);