Wildcard (*.*) [Width].[Precision] specifiers in the printf & sprintf functions ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User13960
Level 3
Level 3
First like received
Greetings all,

Does the DAVE4 'C code' compiler support the Wildcard character * for the Width and Precision fields in the "printf" & "sprint" functions ?


For example...

int16_t Width = 5;
int16_t Precision = 3;
float Number = 1.23456;


sprintf( pBuff, "%*.*f", Width, Precision, Number );

I have tried this but the result is an empty string instead of "1.234"

Thank you very much
PHAB
0 Likes
2 Replies
User13960
Level 3
Level 3
First like received
OK, it seems like I haven't enabled the "Add floating point support for printf" in the "Runtime Library" section for the Microcontroller. Not sure how I do this retrospectively as the option is greyed out.
0 Likes
User13960
Level 3
Level 3
First like received
Yes the wildcard Width and Precision specifiers are supported.

Instructions for enabling the "Add floating point support for printf" in the "Runtime Library" section for the Microcontroller can be found here...

https://www.infineonforums.com/threads/6632-How-to-enable-the-Add-floating-point-support-for-printf-...
0 Likes