简体   繁体   中英

CString Format VS2013

Using the code below sometimes the text variable contains a very huge and strange number, something like "1552505576255083400000000000000000000000000000000000000000000000000000.000". A "0.000" string is expected.

I've also tryed with a basic dialog app and execute these two lines of code in the "OnInitDialog()" I'm using VS 2013. With VS 2003 seems that it works correctly.

can somebody tell me why?

CString text;
text.Format(_T("%.3f"), 0);

Your code has a bug. The %f format specifies requires a floating point number and you specify an integer. To fix the bug, change the 0 to 0.0 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM