Cannot use fclose on output stream, input stream is fine.

Posted by TeeJay on Stack Overflow See other posts from Stack Overflow or by TeeJay
Published on 2010-05-09T09:43:53Z Indexed on 2010/05/09 9:48 UTC
Read the original article Hit count: 185

Filed under:
|
|

Whenever I run my program with fclose(outputFile); at the very end, I get an error. glibc detected...corrupted double-linked list

The confusing thing about this though, is that I have fclose(inputFile); directly above it and it works fine. Any suggestions?

FILE* inputFile = fopen(fileName, "r");
if (inputFile == NULL)
{
    printf("inputFile did not open correctly.\n");
    exit(0);
}
FILE* outputFile = fopen("output.txt", "wb");
if (outputFile == NULL)
{
    printf("outputFile did not open correctly.\n");
    exit(0);
}

/* ... read in inputFile ... */
/* ... some fprintf's to outputFile ... */

fclose(inputFile);
fclose(outputFile);

© Stack Overflow or respective owner

Related posts about c

    Related posts about fclose