Thread: fprintf problem

  1. #1
    Registered User
    Join Date
    May 2007

    fprintf problem

    Hi, I have a problem with fprintf(File *arg1, char * arg2) for I wanted to print an integer or a double variable onto a file. As far as I know, the fprintf command can only allow a string, or a character pointer in argument 2. Can somebody help me in telling me what to do or where to look for in allowing fprintf to accept integer/double variables or possibly ways to convert integer or a double into a char*?

  2. #2
    Fear the Reaper...
    Join Date
    Aug 2005
    Toronto, Ontario, Canada
    The second argument to fprintf is a format string, so it works nearly identically to printf.

    Therefore :

    For doubles :

    fprintf(file_pointer_name, "%f", double_value);
    For intergers :

    fprintf(file_pointer_name,"%d", integer_value);
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Problems writing some chars to files with fprintf
    By Nazgulled in forum C Programming
    Replies: 3
    Last Post: 04-18-2006, 06:00 PM
  3. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  4. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 04:19 PM
  5. Replies: 5
    Last Post: 11-07-2005, 11:34 PM