File opens but write fails

This is a discussion on File opens but write fails within the C Programming forums, part of the General Programming Boards category; The following is a functions that writes a line to a diagnostic file... Code: void Write_to_Diagnostic_Log(const char * const Log_String, ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    278

    File opens but write fails

    The following is a functions that writes a line to a diagnostic file...
    Code:
    void Write_to_Diagnostic_Log(const char * const Log_String, const char * const sDiagnostic_Log_Path) {
      FILE *fpDiagnostic_Log;              // Pointer to the Diagnostic Log File
    
      fpDiagnostic_Log = fopen(sDiagnostic_Log_Path, "a");
    
      if (fpDiagnostic_Log == NULL) printf("\n\n%s\n\n", sDiagnostic_Log_Path);
    
      fprintf(fpDiagnostic_Log, "%s", Log_String);
    
      fclose(fpDiagnostic_Log);  
    }
    The file opens correctly, but nothing prints into it. the fprintf statement returns -1, but I've double checked the fopen and it succeeds...

    What gives?

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    278
    bah... nevermind... I forgot to use a malloc somewhere else and I guess my memory got messed up...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doesn't write in file when call GetSaveFileName()
    By randall81 in forum Windows Programming
    Replies: 1
    Last Post: 03-28-2009, 02:34 PM
  2. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  3. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 08:51 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21