Character 2D Array Question

I am having problems reading a data file to the program. The data file contains players name, points per game, and the player's jersey number. The data file looks like:
DeAndre Parks
0 16.9
It has 13 of these players and it will not read the names specifically, it just spits out garbage numbers when I try to run it. Any help would be appreciated. Thanks.
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
void ReadData(int plyr[], float ppg[], char names [][Name_Size], int size)
{
    ifstream inFile;
    int i;

    inFile.open("points.txt");
    if(!inFile)
    {
        cout << "Error opening points.txt!\n";
        exit (102);

    }
    i = 0;
    while(i < size && !(inFile.getline(names[i], Name_Size).eof()))
    {
        inFile >> plyr[i] >> ppg[i];
        inFile.ignore();

        if(plyr[i] < 0 || plyr[i] > 99 || ppg[i] < 0)
        {
            cout << "Error: invalid data\n";
            plyr[i] = 0;
            ppg[i] = 0;
        }
    i++;
// debug
    for(i = 0; i < size; i++)
        cout << names[i] << " " << plyr[i] << " " << ppg[i] << endl;
    inFile.close();
    }

}
Last edited on
Move line 26 to 29 outside the while loop (after line 30).

By the way: Better change the while into a for loop.
Topic archived. No new replies allowed.