Creating formatted String (including floats) in Arduino-compatible C++ I'm using a Mega2560 and a generic SSD1306 OLED display with the Adafruit_SSD1306 (and by extension, Adafruit_gfx) library.

I need to print a bunch of float values (ranging between 30.0 and 99.9) to the display with exactly one decimal place of precision. The catch is, the Adafruit library doesn't have a printf() method, only one that takes a single ready-to-print string. 

Here's an (obviously non-Arduino) Java-like example of what I'm trying to accomplish:

String foo = String.format("%.1f, %.1f\%", temp1, hum1);
// "display" is my instance of Adafruit_SSD1306
display.print(foo);


So... how can I do something similar in Arduino-compatible C(++)?

Note: for this specific program, I have (relatively speaking) RAM to burn, so I really don't care if whatever library I use to generate formatted Strings is particularly efficient (as long as it isn't leaking). If it wants to use 4k of RAM and 80k of flash to format a 20-character String, so be it.
The Adafruit_GFX class has two methods named print() and
println(). These behave exactly like Serial.print() and
Serial.println(). Specifically, when printing a float, you can provide
a second argument telling it the number of decimal places you want after
the decimal point:

display.print(temp1, 1);  // 1 digit after the decimal point
display.print(", ");
display.print(hum1, 1);  // ditto
display.print("%");


Background: the reason these methods behave like the ones of
Serial is that both Adafruit_GFX and HardwareSerial inherit them
from the Print virtual class.