title: Using an array to read a file
body: <p>What I am trying to do is open a file, read the information in the file, ask the user for a range of data, and calculate the percentage of days in each month that fall into that range. The file is a file with weather data (temperature) for each day of each month, over a course of years. I am having difficulty starting the program with an array and I am not sure how to use the array to get the information from the file, and then calculate and store the information that I need. Any help is appreciated, here's my code so far:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      int range[12], total[12], i, cold, hot, sum, input, month, day, year;
      float avg, temp;
      char filename[20];
  
      printf("Tell me about your preferred temperature for flying:\n");
      printf("What is the coldest temperature you can fly in?\n");
      scanf("%d", &amp;cold);
  
      printf("What is the hottest temperature you can fly in?\n");
      scanf("%d", &amp;hot);
  
      FILE * ifp = 0;
      printf("Please enter the name of the weather data file.\n");
      scanf("%s", filename);
      ifp = fopen(filename, "r");
  
      return 0;
  }
  </code></pre>
  
  <p>Right now I just have the beginning finished and what I think is correct, but I am not sure what to do next with the array in order to get the information out of the text file. I don't need the entire program finished, I just need help on what to do next. Here's an example of what the output should look like:</p>
  
  <pre><code>Tell me about your preferred temperature for flying:
  What is the coldest temperature you can fly in?
  60
  
  What is the hottest temperature you can fly in?
  80
  
  Please enter the name of the weather data file.
  weather.txt
  
  Month 1: 59.2 percent of days in range.
  Month 2: 69.2 percent of days in range.
  Month 3: 72.6 percent of days in range.
  Month 4: 92.6 percent of days in range.
  Month 5: 98.7 percent of days in range.
  Month 6: 48.3 percent of days in range.
  Month 7: 36.41 percent of days in range.
  Month 8: 18.9 percent of days in range.
  Month 9: 57.64 percent of days in range.
  Month 10: 100.00 percent of days in range.
  Month 11: 65.4 percent of days in range.
  Month 12: 80.5 percent of days in range.
  
  I recommend month 10 for the flight!
  </code></pre>
  
  <p>Edit:
  The text file is in this format:</p>
  
  <pre><code>The available data is presented in four columns per day:
  MONTH         DAY         YEAR         TEMPERATURE
  The file will end with a -1 on a row by itself. 
  </code></pre>
  
  <p>Example from the file: </p>
  
  <pre><code> 1             1             2013         63.4
   1             2             2013         66.1
   1             3             2013         67.2
  </code></pre>