d1a424c002
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); \
}
```
21 lines
371 B
C
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);
|
|
}
|