Thread: File opens but write fails

  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, 01: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, 07:51 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM