I am tried to use the dtostrf() function to convert a floating variable to a string array but I am getting the following error ../source/AdcSdkLcd.c:128:9: warning: implicit declaration of function 'dtostrf'; did you mean 'strstr'? [-Wimplicit-function-declaration]. What should I do to convert a floating variable to a string array?
Details:
Using MCUXpresso 10.3.0 IDE
Using Freedom Development Board FRDM-K22F
Trying to display an ADC voltage on a Hitachi 2X16 HD44780U Dot Matrix Liquid Crystal Display Controller/Driver
I am able to display an integer on the LCD with the itoa() function.
The ADC voltage is displaying correctly on the Tera Terminal.
In standard C, you should use sprintf- there are plenty of examples of how to do this.
Con Verse,
Thank you for your replay. I cannot get function sprintf to work with a floating variable. It returns a 0.000
Code:
char buffer1[5];
float value1 = 3.123;
sprintf(buffer1,"%5.3f", value1);
PRINTF("\rUsing function sprintf() to convert floating number %f to a string produces the following string: %s\n", value1, buffer1);
Tera Terminal Display:
Using function sprintf() to convert floating number 3.123000 to a string produces the following string: 0.000
Do you have any suggestions?
Thanks,
Joseph Grigaliunas
To start with your buffer is not long enough - what about the terminating \0?
Con Verse,
I'll try increasing the size of the buffer.
I don't understand what terminating \0 means.
Thanks,
Joseph Grigaliunas