title: Why do I get an assertion failure?
body: <p>This code fails when I try to debug it using VC2010:</p>
  
  <pre><code>char frd[32]="word-list.txt";
  
  FILE *rd=fopen(frd,"r");
  if(rd==NULL)
  {
  std::cout&lt;&lt;"Coudn't open file\t"&lt;&lt;frd;
  exit(1);
  }
  char readLine[100]; 
  while(fgets(readLine, 100, rd) != NULL)
  {     
      readLine[strlen(readLine) - 1] = '\0'; 
      char *token = NULL; 
      token = strtok(readLine, " ,"); 
      insert(readLine);
  } 
  </code></pre>
  
  <p>Debugging results in </p>
  
  <blockquote>
    <p>--------------------------- Microsoft Visual C++ Debug Library-----------</p>
    
    <p>Debug Assertion Failed!</p>
    
    <p>Program: ...\documents\visual studio 2010\Projects\bfa\Debug\bfa.exe
    File: f:\dd\vctools\crt_bld\self_x86\crt\src\fgets.c Line: 57</p>
    
    <p>Expression: ( str != NULL )</p>
    
    <p>For information on how your program can cause an assertion failure,
    see the Visual C++ documentation on asserts.</p>
    
    <p>(Press Retry to debug the application)</p>
    
    <h2>--------------------------- Abort   Retry   Ignore</h2>
  </blockquote>
  
  <p>The errno I get is 2;</p>