Convert float to char array

I have a float variable and want to print it with this function
void SSD1306::string_font6x8(char s) {…}.
This means I need to convert the float to a char array. How do I convert float to char
?

There’s dtostrf, see https://www.hobbytronics.co.uk/arduino-float-vars

You can also utilize the String class

  //create String object from float
  String fabc(1.23, 2 /* decimal places */);
  const char* x = fabc.c_str();
  //iterate char-wise
  for(int i = 0;  i < strlen(x); i++) {
    char current_char = x[i];
  }

There’s also snprintf with the %f format specifier but for that you need to activate a setting to get floating point support, and it increases flash size, see AVR Print float in Atmel Studio 7 using sprintf() and Firmware size increased more than twice after adding _printf_float flag.