为什么这会导致分段错误?
int compareFiles(const char* outFile, const char* expectedFile) {
int N = 10000;
FILE* f1;
FILE* f2;
char buf1[N];
char buf2[N];
f1 = fopen(expectedFile, "r");
f2 = fopen(outFile, "r");
do {
size_t r1 = fread(buf1, 1, N, f1);
size_t r2 = fread(buf2, 1, N, f2);
if (r1 != r2 ||
memcmp(buf1, buf2, r1)) {
return 0;
}
} while (!feof(f1) || !feof(f2));
return feof(f1) && feof(f2);
}