Cannot use fclose on output stream, input stream is fine.
- by TeeJay
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);