Hard to see exactly the issue without knowing what the input file is.
One thing is that you are looping on counter <= numsID. You're probably gone out of range of your values here. Try looping on just counter < numsID.
Second thing is that you're looping on eof(). This is very error prone.
Consider looping on the success of the data extraction itself:
1 2 3 4
|
while (inFileSale >> salesID[counter] >> sales.quarterSales[counter] >> sales.totalSales[counter])
{
counter++;
}
|
1 2 3 4
|
while (inFileID >> sales.idArr[counter]) {
cout << sales.idArr[counter] << endl;
counter++;
}
|
Also, in modern programming, it's considered a "code smell" to be defining variables before they're actually used. It makes the code harder to read and reason about. It's best to get in a good habit now: in readingSales, you don't use numID until it's assigned in line 52.
So, remove line 41, and on line 52, just do
int numsID = counter;
Second, you are using counter for two different purposes.
First, you're using it to counter the number of sales.
Then, you use it to iterate over the existing data.
This could also be cleaned up.