User forums > Using Code::Blocks
"fprintf" to print double data at Win10 with CB16.01
(1/1)
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.
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.
--- End quote ---
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.codeblocks.org/index.php/topic,9996.0.html
Tim S.
Navigation
[0] Message Index
Go to full version