bhavasarbhagyesh:
**HEY GUYS I GOT THE ANSWER FOR, CONVERT FLOATING VALUES IN STRING USING SPRINTF(); FUNCTION **double temp = 55.55;
char buffer[4];sprintf(buffer, "%02.02f", temp);
ssd1306_set_cursor(15, 26);
ssd1306_putstring(buffer);
ssd1306_display();OUTPUT:
55.55
You think? You declare a 4 character array, then expect 6 characters (including the terminating null) to fit in it, for one.
And why does this print "?":-
void setup()
{
Serial.begin(115200);
double temp = 55.55;
char buffer[4];
sprintf(buffer, "%02.02f", temp);
Serial.println(buffer); // Prints "?"
}
void loop(){}
Also why does this print "2":-
void setup()
{
Serial.begin(115200);
double temp = 55.55;
char buffer[4];
sprintf(buffer, "%02.02f", temp);
Serial.println(strlen(buffer)); // Prints "2"
}
void loop(){}