Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Maybe not enough coffee yet, I don't know. All I'm doing is converting between floating point and a formatted string. Wide char code snippet:

C++
double fVal = 1.234;

wchar_t wbuf[16];
char buf[16];
buf[0] = 0;
int dec, sign;

dec = wsprintf(&wbuf[0], _T("%.3f"), fVal);
dec = sprintf(&buf[0], "%.3f", fVal);


The wsprintf call yields "f" The sprint yields "1.234".

I know I'm being stupid, I just know it. What am I missing?
Posted

wsprintf[^] is a Windows function that does NOT handle floating point values. The CRT wide-string equivalent of sprintf is swprintf[^].
 
Share this answer
 
face palm

I knew it, I just knew it. Thank you sir.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900