dtostrf() help

So, the first question is why you are using dtostrf to convert an int to a string. The dtostrf() function is to convert a double (or float) to a string.

The second question is whether or not you have read the documentation on dtostrf. It appears not.

char * 	dtostrf (double __val, signed char __width, unsigned char __prec, char *__s)

The dtostrf() function converts the double value passed in val into an ASCII representationthat will be stored under s. The caller is responsible for providing sufficient storage in s.

Conversion is done in the format "[-]d.ddd". The minimum field width of the output string (including the '.' and the possible sign for negative values) is given in width, and prec determines the number of digits after the decimal sign. width is signed value, negative for left adjustment.

The dtostrf() function returns the pointer to the converted string s.

10 is not a buffer that dtostrf can write to, is it?

1 Like