if( ! (prices[k] > 0)
k = -1;
To restart the loop, you essentially need to reset the counter variable, k. If you get it to -1 when that condition is true, the loop will then increment k as it always does, and then k will be 0.
I'll look over the other code now. So what exactly was being printed when you say it was garbage? I don't have the input files, so I can't test it directly.
By looking at the display function, are *prices and *sold arrays? If so, you can't just print out the array by saying
If they are supposed to be arrays, you need to do a for loop to print out the contents of each array. Also, you'll need to pass in the size of each array so the for loop knows when to stop
for(int i =0; i < arraySize; i++)
cout << prices[i];
If *prices and *sold are meant to be pointers to a int variable, then you need to consider the following: When you just say cout << prices, you're printing out the address of the prices variable, not the value to which it is pointing to. For example:
int i = 10;
int *prt = &i;
cout << prt;
This prints: 0xbffffa08
prt is a pointer that holds the address of i. Just printing the pointer variable like that will print an address. To successfully print it, I need to say
Edited by Tomiger - 1/27/11 at 2:29pm