1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu)
24 .\" Modified Fri Sep 8 15:48:13 1995 by Andries Brouwer (aeb@cwi.nl)
25 .TH GETS 3 2012-01-18 "GNU" "Linux Programmer's Manual"
27 fgetc, fgets, getc, getchar, gets, ungetc \- input of characters and strings
32 .BI "int fgetc(FILE *" stream );
34 .BI "char *fgets(char *" "s" ", int " "size" ", FILE *" "stream" );
36 .BI "int getc(FILE *" stream );
38 .B "int getchar(void);"
40 .BI "char *gets(char *" "s" );
42 .BI "int ungetc(int " c ", FILE *" stream );
46 reads the next character from
54 on end of file or error.
59 except that it may be implemented as a macro which evaluates
65 .BI "getc(" stdin ) \fR.
70 into the buffer pointed to by
72 until either a terminating newline or
74 which it replaces with a null byte (\(aq\\0\(aq).
75 No check for buffer overrun is performed (see BUGS below).
78 reads in at most one less than
82 and stores them into the buffer pointed to by
84 Reading stops after an
87 If a newline is read, it is stored into the buffer.
88 A terminating null byte (\(aq\\0\(aq)
89 is stored after the last character in the buffer.
98 where it is available for subsequent read operations.
99 Pushed-back characters
100 will be returned in reverse order; only one pushback is guaranteed.
102 Calls to the functions described here can be mixed with each other and with
103 calls to other input functions from the
105 library for the same input stream.
107 For nonlocking counterparts, see
108 .BR unlocked_stdio (3).
114 return the character read as an
120 on end of file or error.
128 on error or when end of file occurs while no characters have been read.
137 C89, C99, POSIX.1-2001.
144 ISO C11 removes the specification of
146 from the C language, and since version 2.16,
147 glibc header files don't expose the function declaration if the
149 feature test macro is defined.
153 Because it is impossible to tell without knowing the data in advance how many
156 will read, and because
158 will continue to store characters past the end of the buffer,
159 it is extremely dangerous to use.
160 It has been used to break computer security.
165 It is not advisable to mix calls to input functions from the
167 library with low-level calls to
169 for the file descriptor associated with the input stream; the results
170 will be undefined and very probably not what you want.
185 .BR unlocked_stdio (3),
186 .BR feature_test_macros (7)