title: Reading values from file stream to an array (C)
body: <p>I have been thinking on this for a while. I was given this assignment that says the following: </p>
  
  <p>There is a text file containing numbers. (MIN, MAX, NUMBER) 
  I have to read the contents of the file, then generate a random number between MIN and MAX. If generated number matches the number, then print "Match."</p>
  
  <p>MIN: 7  MAX: 17  NUMBER: 15 
  ...</p>
  
  <p>I was able to read every number into an array, with this code:</p>
  
  <pre><code>int main(void)
  {
      srand(time(NULL));
      int nums[50] = {0};
      int i = 0;
      FILE * fp;
      /*if(fp == NULL) return 1;*/
  
      if (fp = fopen("numbers.txt", "r")) {
          while (fscanf(fp, "%d", &amp;nums[i]) != EOF) {
              ++i;
          }
          fclose(fp);
      }
  
      for (--i; i &gt;= 0; --i)
          printf("num[%d] = %d\n", i, nums[i]);
  
      return 0;
      }
  </code></pre>
  
  <p>However, I have no idea how to continue. How can I assign the specific values to my random number generator function?</p>
  
  <pre><code>int random(int min, int max) {
      return rand()%(max-min+1)+min;
  }
  </code></pre>