fopen Issue

Discussion in 'Win32' started by watson, Jul 24, 2010.

  1. watson

    watson New Member

    Joined:
    Jul 24, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice