Files
RedBear-OS/tests/stdio/fwrite.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

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);
}