Files
RedBear-OS/tests/stdio/fread.c
T
Tibor Nagy d1a424c002 tests: Replace returns with exits in the main functions
This will allow us to redefine the exit function.

For example:
```
#define exit(code) { \
    fprintf(stderr, "%s:%d: exit(%s) in function ‘%s’\n",
        __FILE__, __LINE__, #code, __func__); \
    _exit(code); \
}
```
2019-02-21 12:15:06 +01:00

21 lines
371 B
C

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
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");
exit(EXIT_FAILURE);
}
buf[i] = 0;
printf("%s\n", buf);
}
fclose(fp);
}