Single two dimensional array data file HELP

I'm trying to read numbers from a data file into array but when I compile and run nothing shows up.
what did I do wrong. I have to do all the reading from the function readData and I need to get rid of the header line but I just put that there for myself. Heres the data file

HouseNumber Price
329 155000
459 160000
505 185000
500 215000
345 210000
456 305000
344 405000
501 355000
401 190000
300 170000


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
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
const int HOME_NUMBERS = 10;
const int PRICE = 2;
void programDescription();
void readData(ifstream &inFile,int homeInfo[][PRICE]);
void avgCalc(int homeInfo[][PRICE]);
void sortArray();
void writeResult();
int main()
{
    //Program Description
    //programDescription();
    //Declare variables
    string line;
    int homeInfo[10][2];
    ofstream outFile;
    ifstream inFile;
    //Open file for input
    inFile.open("prices.txt");
    if(inFile.fail())
    {
        cout << "Error opening file" << endl;
        exit(1);
    }
    //Opens file for output
    outFile.open("homeData.txt");
    if(outFile.fail())
    {
        cout << "Error opening file" << endl;
        exit(1);
    }
    //Process data as read and display in tabular format
    //Function call
    readData(inFile,homeInfo);
    //avgCalc(homeInfo);
    return 0;
}
void readData(ifstream &inFile, int homeInfo[][PRICE])
{
    int i = 0;
    while(i < HOME_NUMBERS && !inFile.eof())
    {
        for(int j = 0; j < PRICE; j++)
            homeInfo[i][j];
        i++;
    }
}
void avgCalc(int homeInfo[][PRICE])
{
    float avg = 0;
    float sum = 0;
    for(int i = 0; i < HOME_NUMBERS; i++)
        sum+=homeInfo[i][1];
    avg = sum/PRICE;
    cout << "The average of the prices is: " << avg << endl;
}

Do you think maybe somewhere in readData you ought to actually read from inFile?
I did. I tried everything and I kept getting errors

-8.589933e+008
Last edited on
Topic archived. No new replies allowed.