From 9549e635ac717dbc6c3334c6a608792c22ed010e Mon Sep 17 00:00:00 2001 From: Madeline Busig Date: Wed, 30 Oct 2024 12:50:26 -0700 Subject: [PATCH] Add more comments for problem 3 solution --- src/p3.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p3.c b/src/p3.c index 3a62ad0..9365315 100644 --- a/src/p3.c +++ b/src/p3.c @@ -35,6 +35,10 @@ double sum_file(const char* filename) { // A more reliable way of repeatedly reading from a file is checking // the return value of fscanf. On success, fscanf will return the number // 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) { printf("(fscanf) Adding value %.2lf to sum\n", value);