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
|
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int loadData(ifstream &infile, string months[], int lows[], int highs[], int &rows);
int findLow(int lows[], int rows, int &lowtemp, int &month);
int findHigh(int highs[], int rows, int &hightemp, int &month);
int main()
{
int rows;
string months[rows];
int lows[rows];
int highs[rows];
ifstream infile;
int hightemp;
int lowtemp;
loadData(infile, months, highs, lows, rows);
return 0;
}
int loadData(ifstream &infile, string months[], int lows[], int highs[], int &rows)
{
cout << "In loadData" << endl;
infile.open("temps.txt");
if(!infile)
{
cout << "File did not open. Program terminating.";
exit(0);
}
else
cout << "File is open";
while(!infile.eof())
{
infile >> months[] >> highs[] >> lows[];
rows++;
}
cout << "I count " << rows << "rows.";
}
|