Penguin
Annotated edit history of fgetc(3) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 GETS
2 !!!GETS
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 RETURN VALUE
7 CONFORMING TO
8 BUGS
9 SEE ALSO
10 ----
11 !!NAME
12
13
14 fgetc, fgets, getc, getchar, gets, ungetc - input of characters and strings
15 !!SYNOPSIS
16
17
18 __#include
19 __''stream''__);
20 char *fgets(char *__''s''__, int__ ''size''__, FILE *__''stream''__);
21 int getc(FILE *__''stream''__);
22 int getchar(void);
23 char *gets(char *__''s''__);
24 int ungetc(int__ ''c''__, FILE *__''stream''__);
25 __
26 !!DESCRIPTION
27
28
29 __fgetc()__ reads the next character from ''stream''
30 and returns it as an __unsigned char__ cast to an
31 __int__, or __EOF__ on end of file or
32 error.
33
34
35 __getc()__ is equivalent to __fgetc()__ except that it
36 may be implemented as a macro which evaluates ''stream''
37 more than once.
38
39
40 __getchar()__ is equivalent to
41 __getc(__''stdin''__)__.
42
43
44 __gets()__ reads a line from ''stdin'' into the buffer
45 pointed to by ''s'' until either a terminating newline or
46 __EOF__, which it replaces with __'0'__. No check for
47 buffer overrun is performed (see __BUGS__
48 below).
49
50
51 __fgets()__ reads in at most one less than ''size''
52 characters from ''stream'' and stores them into the
53 buffer pointed to by ''s''. Reading stops after an
54 __EOF__ or a newline. If a newline is read, it is stored
55 into the buffer. A __'0'__ is stored after the last
56 character in the buffer.
57
58
59 __ungetc()__ pushes ''c'' back to ''stream'', cast
60 to __unsigned char__, where it is available for
61 subsequent read operations. Pushed - back characters will be
62 returned in reverse order; only one pushback is
63 guaranteed.
64
65
66 Calls to the functions described here can be mixed with each
67 other and with calls to other input functions from the
68 __stdio__ library for the same input stream.
69 !!RETURN VALUE
70
71
72 __fgetc()__, __getc()__ and __getchar()__ return
73 the character read as an __unsigned char__ cast to an
74 __int__ or __EOF__ on end of file or
75 error.
76
77
78 __gets()__ and __fgets()__ return ''s'' on success,
79 and __NULL__ on error or when end of file occurs while no
80 characters have been read.
81
82
83 __ungetc()__ returns ''c'' on success, or __EOF__
84 on error.
85 !!CONFORMING TO
86
87
88 ANSI - C, POSIX.1
89 !!BUGS
90
91
92 Never use __gets()__. Because it is impossible to tell
93 without knowing the data in advance how many characters
94 __gets()__ will read, and because __gets()__ will
95 continue to store characters past the end of the buffer, it
96 is extremely dangerous to use. It has been used to break
97 computer security. Use __fgets()__ instead.
98
99
100 It is not advisable to mix calls to input functions from the
101 __stdio__ library with low - level calls to __read()__
102 for the file descriptor associated with the input stream;
103 the results will be undefined and very probably not what you
104 want.
105 !!SEE ALSO
106
107
108 read(2), write(2), fopen(3),
109 fread(3), scanf(3), puts(3),
110 fseek(3), ferror(3)
111 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.