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); \
}
```
24 lines
369 B
C
24 lines
369 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
|
|
int main(void) {
|
|
FILE *f = fopen("stdio/fwrite.out", "w");
|
|
const char ptr[] = "Hello World!";
|
|
|
|
if (fwrite(ptr, 0, 17, f)) {
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
if (fwrite(ptr, 7, 0, f)) {
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
if (fwrite(ptr, 0, 0, f)) {
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
fwrite(ptr, sizeof(ptr), 1, f);
|
|
fclose(f);
|
|
}
|