Files
RedBear-OS/tests/stdio/fread.c
T
jD91mZM2 dd711f4dee Fix bug in fread
Bug discovered by @xTibor. Test and input data provided by him.
2018-09-29 15:04:58 +02:00

22 lines
374 B
C

#include <errno.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE *fp = fopen("stdio/fread.in", "rb");
char buf[33] = { 0 };
for (int i = 1; i <= 32; ++i) {
if (fread(buf, 1, i, fp) < 0) {
perror("fread");
return 0;
}
buf[i] = 0;
printf("%s\n", buf);
}
fclose(fp);
return 0;
}