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?
Works for me with Windows 10 32 bit OS and
mingw32-gcc.exe (tdm-1) 4.9.2
Tim S.
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.
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.
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 (http://forums.next.codeblocks.org/index.php/topic,9996.0.html)
Tim S.