title: Debug assertion failed . while using fscanf
body: <p>Hey I've tried a lot of programs in Visual Studio and in most of them when i try taking the input from a stream ( while using <code>fscanf</code> ) it invariably throws a <code>debug assertion failed error ..</code></p>
  
  <p>and goes on to say:</p>
  
  <p><code>stream != NULL</code>. Since I have gotten this error a number of times .. I assume there is a flaw in the way I'm using <code>fscanf</code>. I would appreciate it if someone could tell me the usage or .. give me a demo sample code that illustrates the simple usage .. !</p>
  
  <p>I tried looking up the error .. in most places it said I haven't closed the file .. but I have and I'm a little confused .. I appreciate any help .. thanks a lot :) </p>
  
  <pre><code>    printf("Enter No of states\n");
       Q=5;
    //  scanf("%d",&amp;Q);
  
     // READING ZERO MATRIX
    // reading the matrix from f0.sta
   {
    FILE *fp;
     fp = fopen("c:\\tc\\fuzzy\\f0.sta","r");
     for(i=1;i&lt;=Q;i++)
      for(j=1;j&lt;=Q;j++)
       fscanf(fp,"%f",&amp;a0[i][j]);
  
      fclose(fp);
   }
   // READING ONE MATRIX
   // reading the matrix from f0.sta
     FILE *fp;
      fp = fopen("c:\\tc\\fuzzy\\f1.sta","r");
       for(i=1;i&lt;=Q;i++)
        for(j=1;j&lt;=Q;j++)
          fscanf(fp,"%f",&amp;a1[i][j]);
  
      fclose(fp);
  </code></pre>
  
  <p>This is the code bit. </p>