title: Why the ftell returns 0 in this function?
body: <p>When I run my program and I choose to see the product list, it doesn't print anything. After some time, I find out that the value of <code>fl_size</code> is always 0.  Why is this?</p>
  
  <pre><code>void view_prdct_code_list() {
          FILE *stock = fopen("stock.dat","r+");
          assert(stock);
  
          int fl_size=ftell(stock);
          int prd_size= sizeof(product);
          int quantity= fl_size/prd_size;
          printf("fl_size=%d",fl_size);
  
          fseek(stock,0,SEEK_SET);
          prdct cprd= (product *)malloc (sizeof(product)*quantity);
          assert(cprd);
  
          int i;
  
          fread(cprd,prd_size,quantity,stock);
  
          for (i=0;i&lt;quantity;i++){
                  printf("PRODUCT CODE: %d\n",cprd-&gt;code);
          }
  
          free(cprd);
          fclose(stock);
  }
  </code></pre>