1 /* Regression test for fseek and freopen bugs. */
9 char filename
[] = "/tmp/foo";
12 fp
= fopen (filename
, "w+");
13 fprintf (fp
, "Hello world!\n");
15 fseek (fp
, 5L, SEEK_SET
);
16 if (fseek (fp
, -1L, SEEK_CUR
) < 0)
18 printf ("seek failed\n");
27 char filename1
[] = "/tmp/foo";
28 char filename2
[] = "/tmp/bar";
31 file1
= fopen (filename1
, "w");
34 file2
= fopen (filename2
, "w");
38 file1
= fopen (filename1
, "r");
39 file2
= freopen (filename2
, "r", file1
);
40 if ((ch
= fgetc (file2
)) != 'x')
42 printf ("wrong character in reopened file, value = %d\n", ch
);
51 puts (lose
? "Test FAILED!" : "Test succeeded.");