Thread: input integer in a text file

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    1

    Question input integer in a text file

    like fputs() for string,is there anything for writing integers? further can a structure be used to write in txt file?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Do you want the binary value or the converted readable text value of the number written the file? For the former, you'd want fwrite. For the later you'd likely use fprintf.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    fprintf works just like printf.

  4. #4
    Registered User
    Join Date
    Aug 2010
    Location
    New York
    Posts
    11
    fprintf is like this:

    Code:
    fprintf(FILE *stream, char *args, ...);
    so to write integer 'Cash' to FILE stream:

    Code:
    fprintf(stream, "%d", cash);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you help me about tolower() in file
    By nctar in forum C Programming
    Replies: 7
    Last Post: 05-12-2010, 10:04 AM
  2. Help with finding word frequency in a text file.
    By aeolusaether in forum C Programming
    Replies: 15
    Last Post: 04-04-2010, 09:59 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM

Tags for this Thread