You need a loop. The way your function is situated now, you call it by passing in the array without knowing how many members it has,which doesn't actually matter because you're printing out the first element, incrementing i and then returning. "i" is not maintained between calls, so you're starting at zero each time.
But there's another problem, when you're reading in your data points in main, "i",(which is not connected to the "i" in the display function in any way) is not changing at all, so you're writing each subsequent read from on top of the first elements of each array over and over.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
On line 80+, when you're swapping the agent array, swap the other arrays at the same time. If you're swapping elements 8 and 9 of agent[], swap 8 and 9 of sales also. "i" will give you the index either way. To declutter the code in that region, see if you can come up with a swap function.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
use cout 's to follow your program:
Is your input completely correct? Display what you read and verify it's accurate.
Is your sort testing the correct values? Again, display what you are testing and at least whether or not the values get swapped. You probably don't need to display each value being swapped, just that you're swapping.
Watch for an unexpected value, like going through a loop too many times, or not enough times.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Part of the problem is you should wait until all of the value are read in, and then sort them. You're sorting the empty spots in your array around and potentially overwriting them with the next input.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
Increment i on line 16 instead of count, eliminate line 30, and use another while loop (or a for loop since you know the count) to display the items.
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
while(!ins.eof()) is probably your problem. This should explain your difficulty ( feof is identical to .eof )
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944