Q) sscanf for floating point number.

Dear,

Using “stdio.h”, will sscanf work for floating point?

It seems worked for integer number, but not for floating point number.

I got always the same number which is 1.51*2^-127 for different values after sscanf.

Please share me your experiment.

Thank you.

sscanf and printf on the Arduino don’t support floating point.

When I needed to print a floating point value, I ran into the demented sprintf() problem, and found dtostrf() function that converts a floating point double to a string (you’ll need to allocate space). Glancing through some of the documentation, there’s also a strtod() function which should go the other way, but I’ve never used it.

I suggest you Google dtostrf – you’ll find quite a bit of stuff on the function – much of it is on the Arduino forums.

Use atof() to convert a valid ASCII character string into a floating point number.