title: Scan file contents into an array of a structure
body: <p>I have a structure in my program that contains a particular array. I want to scan a random file with numbers and put the contents into that array.</p>
  <p>This is my code : ( NOTE : This is a sample from a bigger program, so I need the structure and arrays as declared )</p>
  <p>The contents of the file are basically : 5 4 3 2 5 3 4 2</p>
  <pre><code>#include&lt;stdio.h&gt;
  
  #define first 500
  #define sec 500
  
  
  struct trial{
    int f;
    int r;
    float what[first][sec];
  };
  
  int trialtest(trial *test);
  
  main(){
    trial test;
    trialtest(&amp;test);
  }
  
  int trialtest(trial *test){
    int z,x,i;
    FILE *fin;
    fin=fopen(&quot;randomfile.txt&quot;,&quot;r&quot;); 
    for(i=0;i&lt;5;i++){
        fscanf(fin,&quot;%5.2f\t&quot;,(*test).what[z][x]);
      }
    fclose(fin);
    return 0;
  }
  </code></pre>
  <p>But the problem is, whenever this I run this code, I get this error :
  <a href="https://i.stack.imgur.com/wIFFh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wIFFh.png" alt="alt text" /></a></p>
  
  <p><strong>(25) : warning 508 - Data of type 'double' supplied where a pointer is required</strong></p>
  <p>I tried adding</p>
  <pre><code>do{
     for(i=0;i&lt;5;i++){
        q=fscanf(fin,&quot;%5.2f\t&quot;,(*test).what[z][x]);
      }
    }while(q!=EOF);
  </code></pre>
  <p>But that didnt work either, it gives the same error.</p>
  <p>Does anyone have a solution to this problem ?</p>