warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
On success, these functions return the number of input items
successfully matched and assigned; this can be fewer than
provided for, or even zero, in the event of an early
matching failure.
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
+#include <assert.h>
#include "mmio.h"
/* (ANSI C X3.159-1989, Sec. 4.9.6.2, p. 136 lines 13-15) */
for (i = 0; i < nz; i++) {
- fscanf(f, "%d %d %lg\n", &I[i], &J[i], &val[i]);
+ int num = fscanf(f, "%d %d %lg\n", &I[i], &J[i], &val[i]);
+ (void)num;
+ assert(num == 3);
I[i]--; /* adjust from 1-based to 0-based */
J[i]--;
}