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 1993-04-04 "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 .BI "int getchar(void);"
40 .BI "char *gets(char *" "s" );
42 .BI "int ungetc(int " c ", FILE *" stream );
45 reads the next character from
53 on end of file or error.
58 except that it may be implemented as a macro which evaluates
64 .BI "getc(" stdin ) \fR.
69 into the buffer pointed to by
71 until either a terminating newline or
73 which it replaces with
75 No check for buffer overrun is performed (see
80 reads in at most one less than
84 and stores them into the buffer pointed to by
86 Reading stops after an
88 or a newline. If a newline is read, it is stored into the buffer. A
90 is stored after the last character in the buffer.
99 where it is available for subsequent read operations. 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 non-locking 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.
143 Because it is impossible to tell without knowing the data in advance how many
146 will read, and because
148 will continue to store characters past the end of the buffer, it is extremely
149 dangerous to use. It has been used to break computer security. Use
153 It is not advisable to mix calls to input functions from the
155 library with low-level calls to
157 for the file descriptor associated with the input stream; the results
158 will be undefined and very probably not what you want.
172 .BR unlocked_stdio (3)