aboutsummaryrefslogtreecommitdiff
path: root/tests/write.c
blob: 5ccbc9014766869045294a6cac68e0e1d580ec89 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <signal.h>
#include <stdio.h>

int main(void) {
    FILE *fp = NULL;
    int b = 1;
    char c = '\0';
    if ((fp = tmpfile()) == NULL) {
        perror("tmpfile");
        raise(SIGABRT);
    }
    for (;;b++) {
        if (fwrite(&c, 1, 1, fp) == 0) {
            perror("fwrite");
            raise(SIGABRT);
        }
        if (b % 1000 == 0) {
            fprintf(stderr, "Wrote %u octets\n", b);
        }
    }
}