That helped a lot! My program seems to only run through the first auction though, this is the output:
Auction 1 sold for $100.
Auction 2 sold for $500.
Auction 3 sold for $500.
Auction 4 sold for $500.
I'm guessing my first loops are incorrect?
Code:
# include <stdio.h># include <stdlib.h>
# include <time.h>
int main () {
FILE * ifp;
ifp = fopen("bids.txt", "r");
float winning_bid[5];
int num_auctions, num_bids, max_bid=0, current_bid, next_bid, i, j,sum=0;
fscanf(ifp, "%d", &num_auctions);
//Loop set up based on the number of auctions
for (i=0; i<num_auctions; i++) {
fscanf(ifp, "%d", &num_bids);
for (i=0; i<num_bids; i++) {
fscanf(ifp, "%d", ¤t_bid);
if (current_bid > max_bid )
max_bid = current_bid;
printf("Auction %d sold for $%d.\n", i+1, max_bid);
}
//keep a running sum of total made from auctions
}
}