avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] lcdprint with dtostrf


From: James Hamilton
Subject: Re: [avr-gcc-list] lcdprint with dtostrf
Date: Sat, 15 Jul 2017 21:10:10 -0400

​Ismail: could you please post more of your code, especially the definition of buffer?  Also, do you have the word "float" in your call to stostrf, or were you just letting us know that "number" is a float?  The type of "number" should not be in the call to dtostrf().  From some forum posts, it looks like there may be a bug with dtostrf() when using a float instead of a double.  Can you try using a double for "number" instead of a float?

All: I haven't used dtostrf() before, but based on my cursory glance at it's definition, it seems unsafe (in the snprintf vs sprintf sense).  Am I missing something that would prevent a buffer overflow when using dtostrf(), or is assumed that the caller knows how to test the length of the string the double will produce before calling dtostrf()?  Is there a version of dtostrf() that accepts a max length argument (other than snprintf)?

73,

~James

On Sat, Jul 15, 2017 at 3:47 PM,
​​
Ismail <address@hidden> wrote:
hi, i am having difficulty in sending a floating point number to lcd. 

i ham using 

dtostrf(float number, 5,2, buffer);
lcdprint(buffer); 

but invain

reply via email to

[Prev in Thread] Current Thread [Next in Thread]