xref: /relibc/tests/stdio/fwrite.c (revision be35961d82cd98f2a2e61c4f1869271b9f4af571)
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 
5 #include "test_helpers.h"
6 
7 int main(void) {
8     FILE *f = fopen("stdio/fwrite.out", "w");
9     ERROR_IF(fopen, f, == NULL);
10 
11     const char ptr[] = "Hello World!";
12 
13     if (fwrite(ptr, 0, 17, f)) {
14         exit(EXIT_FAILURE);
15     }
16 
17     if (fwrite(ptr, 7, 0, f)) {
18         exit(EXIT_FAILURE);
19     }
20 
21     if (fwrite(ptr, 0, 0, f)) {
22         exit(EXIT_FAILURE);
23     }
24 
25     fwrite(ptr, sizeof(ptr), 1, f);
26     fclose(f);
27 }
28