CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: fopen Bug?

Threaded View

  1. #1
    Join Date
    Jan 2004
    Location
    Near Portland, OR
    Posts
    222

    fopen Bug?

    I'm trying to track some problems in my code with trusty old log file method (looking at data patterns in a large data stream). I've done this many times before, but I'm getting an occasional error in my call to fprintf after fopen. The thing is that it opens and closes the file many times before triggering the error.

    Code:
        FILE *fptr=0;
        char filename[256]="DebugFile.txt";
        DWORD err;
    
        fptr=fopen(filename,"a+");
        if(fptr==0)
        {
            err=GetLastError(); 
        }
    ...
        fprintf(fptr,"Some debug text\n");
    When I put a break point on GetLastError and catch the last error, the code is 183, which according to MSDN is "Cannot create a file when that file already exists."

    Is there some limit to the number of times you can open and close a file in a certain period of time and it throws a bogus error if you exceed it? That's the only thing I can think of here.

    Bill
    Last edited by Marc G; July 21st, 2010 at 09:27 AM. Reason: fixed code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured