Wed Jan 24 04:18:36 1996 Paul Eggert <eggert@twinsun.com>
[glibc.git] / stdio-common / bug3.c
blob1684720b9fd8e2f22e1f24201118d2674c2310fb
1 #include <ansidecl.h>
2 #include <stdio.h>
3 #include <string.h>
5 int
6 DEFUN_VOID(main)
8 FILE *f;
9 int i;
11 f = fopen("/tmp/bugtest", "w+");
12 for (i=0; i<9000; i++)
13 putc ('x', f);
14 fseek (f, 8180L, 0);
15 fwrite ("Where does this text go?", 1, 24, f);
16 fflush (f);
18 rewind (f);
19 for (i=0; i<9000; i++)
21 int j;
23 if ((j = getc(f)) != 'x')
25 if (i != 8180)
27 printf ("Test FAILED!");
28 return 1;
30 else
32 char buf[25];
34 buf[0] = j;
35 fread (buf + 1, 1, 23, f);
36 buf[24] = '\0';
37 if (strcmp (buf, "Where does this text go?") != 0)
39 printf ("%s\nTest FAILED!\n", buf);
40 return 1;
42 i += 23;
47 fclose(f);
49 puts ("Test succeeded.");
51 return 0;