Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

sprintf with float?

$
0
0

Actually I'm not able to get the correct ouput, formating a float number, not knowing what's going wrong:

(no problems when using int, DWORD  and strings)

#include <stdio.h>

void func(void)

{

char c[25];

float f = 2.5;

sprintf(c, "%5.2f", f );.

}

expected output: "   2.50"

but I get always "-..0" (or anything else what makes no sense)

If tried several variants but I never get a correct result. May be I link a wrong lib or is there any additional type cast necessary?

Any help very appreciated! Thank you very much.

Best regards

Ralph


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>