Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: klion717 on September 07, 2017, 09:30:40 am

Title: "fprintf" to print double data at Win10 with CB16.01
Post by: klion717 on September 07, 2017, 09:30:40 am
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?
Title: Re: "fprintf" to print double data at Win10 with CB16.01
Post by: stahta01 on September 07, 2017, 10:28:00 am
Works for me with Windows 10 32 bit OS and
mingw32-gcc.exe (tdm-1) 4.9.2

Tim S.
Title: Re: "fprintf" to print double data at Win10 with CB16.01
Post by: sodev on September 07, 2017, 06:26:17 pm
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.
Title: Re: "fprintf" to print double data at Win10 with CB16.01
Post by: 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.
Title: Re: "fprintf" to print double data at Win10 with CB16.01
Post by: stahta01 on September 11, 2017, 08:29:41 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.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)

Tim S.