News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

"fprintf" to print double data at Win10 with CB16.01

Started by klion717, September 07, 2017, 09:30:40 AM

Previous topic - Next topic

klion717

When I use fprintf to print double data to the screen with the following format, it always shows 0.00 on the screen.
Note that I am working at Win10 with CB16.01.
double db_data=0.5;
fprintf(stdout,"db_data = %.2lf \n",db_data);  //lf for double

When I run it at Win7 with CB16.01 with the same compiler configuration, it is OK.

Does anyone have the same problem?

stahta01

Works for me with Windows 10 32 bit OS and
mingw32-gcc.exe (tdm-1) 4.9.2

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

sodev

Which compiler? Which flavour (32, 64 bit)? C code? C++ code? C++11 mode? Why the l in front of the f? Try without the l.

klion717

C with compiler mingw32-gcc.exe.
'lf' means double, 'f' means float, if I remove 'l', it works. But I think 'lf' is more accurate.

stahta01

Quote from: klion717 on September 11, 2017, 08:21:22 AM
C with compiler mingw32-gcc.exe.
'lf' means double, 'f' means float, if I remove 'l', it works. But I think 'lf' is more accurate.

That is only for scanf; for printf 'f' means float or double.

To confirm this search the web because it is off topic for this site.
Link to rules: http://forums.next.codeblocks.org/index.php/topic,9996.0.html

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]