2 * Print buffering for various standard I/O streams
8 void pr_stdio(const char *name
, FILE *fp
)
10 printf("stream = %s, ", name
);
12 if (fp
->_flags
& _IONBF
)
14 else if (fp
->_flags
& _IOLBF
)
15 printf("line buffered");
17 printf("fully buffered");
26 fputs("enter any character\n", stdout
);
27 if (getchar() == EOF
) {
31 fputs("one line to standard error\n", stderr
);
33 pr_stdio("stdin", stdin
);
34 pr_stdio("stdout", stdout
);
35 pr_stdio("stderr", stderr
);
37 if ((fp
= fopen("/etc/passwd", "r")) == NULL
) {
38 fprintf(stderr
, "fopen() error");
41 if (getc(fp
) == EOF
) {
42 fprintf(stderr
, "getc() error");
46 pr_stdio("/etc/passwd", fp
);