source: trunk/src/libctests/glibc/stdio-common/tst-ferror.c@ 2036

Last change on this file since 2036 was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 895 bytes
Line 
1#include <stdio.h>
2
3int
4main (int argc, char *argv[])
5{
6 char buf[100];
7 int result = 0;
8
9 if (ferror (stdin) != 0)
10 {
11 fputs ("error bit set for stdin at startup\n", stdout);
12 result = 1;
13 }
14 if (fgets (buf, sizeof buf, stdin) != buf)
15 {
16 fputs ("fgets with existing input has problem\n", stdout);
17 result = 1;
18 }
19 if (ferror (stdin) != 0)
20 {
21 fputs ("error bit set for stdin after setup\n", stdout);
22 result = 1;
23 }
24 if (fputc ('a', stdin) != EOF)
25 {
26 fputs ("fputc to stdin does not terminate with an error\n", stdout);
27 result = 1;
28 }
29 if (ferror (stdin) == 0)
30 {
31 fputs ("error bit not set for stdin after fputc\n", stdout);
32 result = 1;
33 }
34 clearerr (stdin);
35 if (ferror (stdin) != 0)
36 {
37 fputs ("error bit set for stdin after clearerr\n", stdout);
38 result = 1;
39 }
40 return result;
41}
Note: See TracBrowser for help on using the repository browser.