This code fails when I try to debug it using VC2010:
char frd[32]="word-list.txt";
FILE *rd=fopen(frd,"r");
if(rd==NULL)
{
std::cout<<"Coudn't open file"<<frd;
exit(1);
}
char readLine[100];
while(fgets(readLine, 100, rd) != NULL)
{
readLine[strlen(readLine) - 1] = '';
char *token = NULL;
token = strtok(readLine, " ,");
insert(readLine);
}
Debugging results in
--------------------------- Microsoft Visual C++ Debug Library-----------
Debug Assertion Failed!
Program: ...documentsvisual studio 2010ProjectsfaDebugfa.exe File: f:ddvctoolscrt_bldself_x86crtsrcfgets.c Line: 57
Expression: ( str != NULL )
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
--------------------------- Abort Retry Ignore
The errno I get is 2;
See Question&Answers more detail:os