Writing a function that iterates through an array

My program is supposed to read in data from a .txt file and print out an extensive data analysis. I've accomplished the first task of reading in the file and printing out the number of riders, but I'm having problems singling out a set of numbers in the middle of my array that represents the duration of the bike ride, in order to calculate the avg ride duration.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  int InputRideData(string filename, int bikeids[], int durations[], int genders[], int birthyears[])
{
    ifstream file;
   
 //  cin >> filename1;
   
   file.open(filename.c_str());
   int numPeople = 0;
   int N = 0;
   
   file >> numPeople;
   
   while (!file.eof())
    {
      bikeids[N] = numPeople; // store it:
      N = N + 1; // count it
      file >> numPeople;
        
    }
   
  // file.close();
  // cout << "# of lines: " << N1 << endl;
   //return N1;
  
  
  
  
  return N / 4;
}
  





// AvgDuration
//
// Returns the average ride duration.
//
double AvgDuration(int durations[], int N)
{

  double avg = 0.0; 
   
  
  

  
  return avg;
}


// the data set looks like:

1234 888 1 1984
^
these digits are the placeholders for the time in seconds
Last edited on
Topic archived. No new replies allowed.