2 * setvbuf() usage example
15 file
= fopen("./buf_test2.txt", "w+");
17 fprintf(stderr
, "file cannot be openned\n");
21 /* set the stream buffer and the it as fully-buffered */
22 memset(buf
, '\0', sizeof(buf
));
23 err
= setvbuf(file
, buf
, _IOFBF
, sizeof(buf
));
25 fprintf(stderr
, "sevbuf() failed\n");
29 /* write data and exit */
30 fprintf(file
, "Go, go! Goooooo Jhonny go, go! Goooooo Jhonny go, go!\n");
33 /* shows the contents of 'buf' */
34 fprintf(stdout
, "buf: %s", buf
);