I have a text file that contains a list of IDs and sales amounts. I need to read it into a 2D array. I also need it to accumulate sales for each ID instead of repeating the ID in my array. I can't even get the file read into an array. Here's what I have. What am I doing wrong?
ifstream inFile;
inFile.open(filename);
if (!inFile)
cout << "Error opening file.\n";
for (int i = 0; i < 50; i++)
{
for (int j = 0; j < 50; j++)
{
inFile >> salesArr[i][j];
cout << salesArr[i][j];
}
}
Here is some of the data from the text file:
254 670.00
689 520.00
691 4800.00
828 3860.00
848 2820.00
229 7848.00
828 607.00
848 820.00
229 815.00
546 1280.00
828 660.00
848 320.00