1 #include <stdio.h>
2
3
writestuff(FILE * f)4 void writestuff (FILE *f)
5 {
6 fprintf (f, "hello world\n");
7 fputc ('y', f);
8 putc ('e', f);
9 }
10
readstuff(FILE * f)11 void readstuff (FILE *f)
12 {
13 int c, d;
14 char stuff[100], *s;
15 c = fgetc (f);
16 ungetc (c, f);
17 d = fgetc (f);
18 s = fgets (stuff, sizeof(stuff), f);
19 }
20
main()21 int main ()
22 {
23 FILE *f;
24 writestuff (stdout);
25 writestuff (stderr);
26 f = fopen ("/dev/null", "w");
27 writestuff (f);
28 fclose (f);
29 f = fopen ("/dev/zero", "r");
30 readstuff (f);
31 f = freopen ("/dev/null", "w", f);
32 writestuff (f);
33 fclose (f);
34
35 return 0;
36 }
37