Step 7 of 7
Challenge: a CSV report
A realistic batch job: read input data, aggregate it, write an output file.
sales.csv starts with a header line, then region,amount rows (amounts are whole dollars). Your turn:
- Skip the header, then total the amounts per region (at most 10 regions, names up to 15 characters), keeping regions in the order they first appear.
- Write
report.txtwith oneREGION TOTALline per region. - Then read
report.txtback and print it, so the test can see what you wrote.
Tip: sscanf(line, "%15[^,],%d", region, &amount) reads everything up to the comma as the region, then the number.