Thread: Writing to file

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Writing to file

    Hey guys, quick question
    Code:
    fprintf(r,"%f\n",*k);
    This line should print a number to file. if i *k is in float format every thing's OK, but i need to use double. Than this line prints 0. what should i do? how should i change it? or there could be a problem with my main code?

  2. #2
    Registered User Maz's Avatar
    Join Date
    Nov 2005
    Location
    Finland
    Posts
    194
    you could try %lf (long float)

    EDIT:

    especially if you take inputs with scanf, I believe printf should work with %f too.
    Last edited by Maz; 04-15-2009 at 01:21 PM.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    4
    Exactly what i was looking for. Thanks a lot man

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 10:47 AM
  3. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  4. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM