So I have a program I need to make which involves an array. It builds fine and runs. Right now I just need to get the array to read in from file then print it on screen. But only a little over half the array prints (the last half). format of file is:
day/time/count of something
01 - 20:21 - 67
01 - 21:18 - 44
01 - 23:10 - 44
02 - 00:42 - 66
02 - 02:11 - 56
02 - 04:10 - 82
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
const int a=477;
int i;
char filler;
class Pollution
{
private:
public:
double count[a], day[a], time[a], hr, min;
void print_data (),
read_data (ifstream&);
};
class Analysis
{
private:
public:
int maximum ();
double average ();
};
void Pollution::read_data (ifstream& readfile)
{
for (i=0;i<a;i++)
{
readfile>> day[i] >>filler >>hr >>filler >>min >>filler >>count[i];
time[i] = hr*100+min;
}
}
void Pollution::print_data ()
{
for(i=0; i<a; i++)
{
cout<< day[i]<<":"<<time[i]<<":"<<count[i]<<endl;
}
}
int main()
{
Pollution co2;
ifstream infile ("C:\\pollution_level.txt");
co2.read_data (infile);
co2.print_data ();
}