Add more comments for problem 3 solution

This commit is contained in:
Madeline Busig 2024-10-30 12:50:26 -07:00
parent 73983c2c6f
commit 9549e635ac

View File

@ -35,6 +35,10 @@ double sum_file(const char* filename) {
// A more reliable way of repeatedly reading from a file is checking // A more reliable way of repeatedly reading from a file is checking
// the return value of fscanf. On success, fscanf will return the number // the return value of fscanf. On success, fscanf will return the number
// of values read. // of values read.
//
// Do note, using the return value of fscanf means that if an unexpected
// value is encountered, we will stop reading and any remaining values
// will be skipped.
while (fscanf(infile, "%lf", &value) == 1) { while (fscanf(infile, "%lf", &value) == 1) {
printf("(fscanf) Adding value %.2lf to sum\n", value); printf("(fscanf) Adding value %.2lf to sum\n", value);