title: Sparse matrix problem(there is a problem in my scan_matrix function)
body: <p>I'm trying to write a matrix to sparse matrix conversion program.
  But, there is a problem in my scan_matrix function.I couldn't figure out where is the problem.According to Nemiver(debugging program) problem is in my fscanf call...
  My piece of code:</p>
  
  <pre><code>void scan_matrix(FILE *inp, struct sparse_m mysparse[], int *place_p)
  {
      int matrix[9][9];
      int row,column,place=0;
      for(column=0;column&lt;9;column++){
          for(row=0;row&lt;9;row++){
              fscanf(inp, "%d", &amp;matrix[row][column]);
          }
      }
      for(column=0;column&lt;9;column++){
          for(row=0;row&lt;9;row++){
              if( matrix[row][column] != 0 ) {
                  mysparse[place++].row = row;
                  mysparse[place++].column = column;
                  mysparse[place++].value = matrix[row][column];
              }
          }
      }
      *place_p = place;
  }
  </code></pre>
  
  <p>and my two dimensional matrix:</p>
  
  <pre><code>64  -16     0   -16     0     0     0     0     0
  -16  64   -16     0   -16     0     0     0     0
  0   -16    64     0     0   -16     0     0     0
  -16   0     0    64   -16     0   -16     0     0
  0   -16     0   -16    64   -16     0   -16     0
  0     0   -16     0   -16    64     0     0   -16
  0     0     0   -16     0     0    64   -16     0
  0     0     0     0   -16     0   -16    64   -16
  0     0     0     0     0   -16     0   -16    64
  </code></pre>
  
  <p>The output must be something like this;</p>
  
  <pre><code>(3, 0)  64
  (4, 1)  -16
  (5, 2)  -16
  (6, 3)  -16
  (7, 4)  64
  (8, 5)  -16
  (7, 6)  -16
  (8, 7)  -16
  (8, 8)  64
  </code></pre>
  
  <p>my full code;</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  struct sparse_m {
      int row,
          column,
          value;
  };
  void write_sparse(FILE *outp, struct sparse_m mysparse[], int c);
  void scan_matrix(FILE *inp, struct sparse_m mysparse[],int *place_p);
  
  int main(void)
  {
      int a = 0;
      FILE *inp_txt;
      FILE *outp_txt;
      inp_txt = fopen("s_matrix.dat", "r");
      outp_txt = fopen("sparse.dat", "w");
      struct sparse_m mys[10];
      scan_matrix(inp_txt, mys,&amp;a);
      write_sparse(outp_txt,mys,a);
  
      return(0);
  }
  void scan_matrix(FILE *inp, struct sparse_m mysparse[], int *place_p)
  {
      int matrix[9][9];
      int row,column,place=0;
      for(column=0;column&lt;9;column++){
          for(row=0;row&lt;9;row++){
              fscanf(inp, "%d", &amp;matrix[row][column]);
          }
      }
      for(column=0;column&lt;9;column++){
          for(row=0;row&lt;9;row++){
              if( matrix[row][column] != 0 ) {
                  mysparse[place++].row = row;
                  mysparse[place++].column = column;
                  mysparse[place++].value = matrix[row][column];
              }
          }
      }
      *place_p = place;
  }
  
  void write_sparse(FILE *outp, struct sparse_m mysparse[], int c)
  {
      int i;
      printf("%d---", c);
      for(i=0;i&lt;c;i++){
          fprintf(outp, "(%d, %d)  %d\n", mysparse[i].row,
                                          mysparse[i].column,
                                          mysparse[i].value);
      }
  }
  </code></pre>