I am working wih LpcXpresso IDE and have problems to use the function sprintf() with float conversion. A lot of hints are available in the internet (e.g. uses -u _printf_float). But I do not know, how to handle this. Can anybody give me a solution?
For me I found something in the linker settings. Project Properties.
checkboxes for printf and scanf floats.
- this seemed to work for sprintf too.
So is your project configured to use Redlib, Newlib or NewlibNano as your selected C library?
If you are using Redlib, then make sure you haven't got CR_INTEGER_PRINTF symbol defined:
And if you are using NewlibNano, then make sure you have "Enable printf/scanf float" enabled in Project properties:
If you need further assistance, then please confirm the version of LPCXpresso IDE that you are using, and export and post an example project that shows up your problem:
https://community.nxp.com/message/630625
Regards,
LPCXpresso Support
Here is the code example:
char temp[20];
float wert=1.234
sprintf(temp,"%1.3f",wert)
The result is an empty string. If I use an integer wert and format it with "%d" I get the right string.
Very hard to give a solution if you don't describe the problem. Please describe exactly your problem and show us the code you are using.