Author Topic: "fprintf" to print double data at Win10 with CB16.01  (Read 3454 times)

Offline klion717

  • Single posting newcomer
  • *
  • Posts: 2
"fprintf" to print double data at Win10 with CB16.01
« 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?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: "fprintf" to print double data at Win10 with CB16.01
« Reply #1 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sodev

  • Regular
  • ***
  • Posts: 497
Re: "fprintf" to print double data at Win10 with CB16.01
« Reply #2 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.

Offline klion717

  • Single posting newcomer
  • *
  • Posts: 2
Re: "fprintf" to print double data at Win10 with CB16.01
« Reply #3 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.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: "fprintf" to print double data at Win10 with CB16.01
« Reply #4 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

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