Help with arrays and files

I have a project to write and am having trouble with how to start. I am using visual studios. The first part of the prompt is
"One function should open the file and read the first line that contains the number of formulations
(the first value) and number of plants (the second value). Using these values, your function
should then read the rest of the data and store the values in a 2-dimensional array. As the
compressive strengths are being stored, a message should be output if any compressive strength
is not in the range of 15 to 75 MPa. The message should output the formulation, plant and
compressive strength as the example below."

I know how to open the file but from there I don't know how to get the first two numbers of the file to determine how big my array is or how to store the rest of my values into a 2D array. please help!

this is the file


19 8
43.16 41.54 33.30 42.07 37.45 35.87 37.43 35.59
43.63 48.47 48.23 48.25 46.01 40.38 46.15 48.89
28.47 30.10 29.18 26.09 27.88 24.64 29.67 23.56
15.72 16.76 8.22 25.75 21.30 16.98 25.48 23.15
59.59 59.03 61.28 61.25 56.54 59.88 59.34 62.51
34.37 34.44 26.55 30.31 25.14 25.55 29.97 36.13
66.92 71.49 69.10 74.47 65.64 70.13 72.21 74.40
61.18 55.34 49.03 52.03 50.75 64.40 52.54 57.99
41.04 46.44 38.18 34.99 34.89 44.44 41.11 41.02
77.10 71.46 70.99 77.94 65.98 73.48 74.18 68.78
29.08 22.17 22.26 28.52 31.61 40.93 24.67 28.94
69.59 60.33 67.81 61.03 74.20 65.56 70.50 67.28
56.21 52.60 56.96 57.96 61.85 54.22 46.45 51.64
65.42 55.71 63.84 60.50 65.75 52.16 59.21 55.17
35.72 29.48 31.14 23.83 25.59 26.18 30.30 26.17
50.10 41.84 46.94 45.53 43.27 49.52 48.85 48.10
55.00 62.38 60.05 58.10 59.07 58.21 53.75 58.14
59.51 59.06 58.53 60.40 55.99 64.89 63.56 61.94
67.90 65.61 71.06 67.60 65.86 72.05 67.33 66.23

Here is a simple demo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

using namespace std;

int main()
{
  int formulation = 0, num_plants = 0;

  ifstream src("filename");
  if (!src)
  {
    perror("Error: ");
    exit(EXIT_FAILURE);
  }
  src >> formulation >> num_plants;
  // TODO
  // Create your array and read the data into it

  system("pause");
  return 0;
}
Topic archived. No new replies allowed.