Commit | Line | Data |
---|---|---|
8bdcef8d KB |
1 | .\" Copyright (c) 1989 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms are permitted | |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | .\" | |
16 | .\" @(#)gets.3 6.3 (Berkeley) %G% | |
2e146d0b | 17 | .\" |
86198885 | 18 | .TH GETS 3 "" |
2e146d0b KM |
19 | .AT 3 |
20 | .SH NAME | |
8bdcef8d | 21 | gets - get a line from stdin |
2e146d0b | 22 | .SH SYNOPSIS |
8bdcef8d KB |
23 | .nf |
24 | .ft B | |
25 | #include <stdio.h> | |
26 | ||
27 | char *gets(s) | |
28 | char *s; | |
29 | .ft R | |
30 | .SH DESCRIPTION | |
31 | .ft B | |
32 | This interface is obsoleted by fgets(3). | |
33 | As it makes no effort to avoid overwriting its buffer, | |
34 | it's a clear security problem. | |
2e146d0b | 35 | .br |
8bdcef8d KB |
36 | It is available from the compatibility library, libcompat. |
37 | .ft R | |
2e146d0b | 38 | .PP |
8bdcef8d KB |
39 | The |
40 | .I gets | |
41 | function reads characters from the input stream pointed to by | |
42 | .IR stdin , | |
43 | into the array pointed to by | |
44 | .IR s , | |
45 | until end-of-file is encountered or a new-line character is read. | |
46 | Any newline character is discarded, and a null character is written | |
47 | immediately after the last character read into the array. | |
2e146d0b | 48 | .PP |
8bdcef8d KB |
49 | The |
50 | .I gets | |
51 | function returns | |
2e146d0b | 52 | .I s |
8bdcef8d KB |
53 | if successful. |
54 | If end-of-file is encountered and no characters have been read into | |
55 | the array, the contents of the array remain unchanged and a null | |
56 | pointer is returned. | |
57 | If a read error occurrs during the operation, the array contents | |
58 | are indeterminate and a null pointer is returned. | |
2e146d0b | 59 | .SH "SEE ALSO" |
8bdcef8d KB |
60 | getc(3), ferror(3) fread(3), scanf(3) |
61 | .SH STANDARDS | |
62 | The | |
63 | .I gets | |
64 | function is ANSI C compatible. |