I'm back again, with another fgets issue (sort of).
I've used this code numerous times, as it's quite standard, but for some reason I'm getting an error now.
Code:
Debug Assertion Failed
File: fgets.c
Line: 60
Expression: str != NULL
And the parcel of code giving me the error (actually, I isolated it to just the while(fgets()!=NULL) loop - the code inside the loop has no influence).
Code:
FILE *cFile;
char Line[100];
// Check for match before opening file
if(strcmp(STRTOCOMP1, STRTOCOMP2) == 0)
{
cFile = fopen(FILENAME, "r");
// If the file cannot be read, warn the user
if(!inp)
{
MessageBox(Msg, "Error", MB_OK | MB_ICONEXCLAMATION);
return;
// If the file can be read, proceed to read it in
} else
{
while(fgets(Line, sizeof Line, cFile) != NULL)
{
// sscanf() stuff to a struct vector
}
fclose(cFile);
}
// If there was no match, warn the user
} else
{
MessageBox(Msg, "Error", MB_OK);
}
The code seems flawless -- why would it be throwing an assertion error? Unless I'm missing something completely obvious, which is kind of why I'm asking for help.