Commit | Line | Data |
---|---|---|
8bdcef8d KB |
1 | .\" Copyright (c) 1989 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
91cff1e1 | 4 | .\" %sccs.include.redist.man% |
8bdcef8d | 5 | .\" |
91cff1e1 | 6 | .\" @(#)gets.3 6.4 (Berkeley) %G% |
2e146d0b | 7 | .\" |
86198885 | 8 | .TH GETS 3 "" |
2e146d0b KM |
9 | .AT 3 |
10 | .SH NAME | |
8bdcef8d | 11 | gets - get a line from stdin |
2e146d0b | 12 | .SH SYNOPSIS |
8bdcef8d KB |
13 | .nf |
14 | .ft B | |
15 | #include <stdio.h> | |
16 | ||
17 | char *gets(s) | |
18 | char *s; | |
19 | .ft R | |
20 | .SH DESCRIPTION | |
21 | .ft B | |
22 | This interface is obsoleted by fgets(3). | |
23 | As it makes no effort to avoid overwriting its buffer, | |
24 | it's a clear security problem. | |
2e146d0b | 25 | .br |
8bdcef8d KB |
26 | It is available from the compatibility library, libcompat. |
27 | .ft R | |
2e146d0b | 28 | .PP |
8bdcef8d KB |
29 | The |
30 | .I gets | |
31 | function reads characters from the input stream pointed to by | |
32 | .IR stdin , | |
33 | into the array pointed to by | |
34 | .IR s , | |
35 | until end-of-file is encountered or a new-line character is read. | |
36 | Any newline character is discarded, and a null character is written | |
37 | immediately after the last character read into the array. | |
2e146d0b | 38 | .PP |
8bdcef8d KB |
39 | The |
40 | .I gets | |
41 | function returns | |
2e146d0b | 42 | .I s |
8bdcef8d KB |
43 | if successful. |
44 | If end-of-file is encountered and no characters have been read into | |
45 | the array, the contents of the array remain unchanged and a null | |
46 | pointer is returned. | |
47 | If a read error occurrs during the operation, the array contents | |
48 | are indeterminate and a null pointer is returned. | |
2e146d0b | 49 | .SH "SEE ALSO" |
8bdcef8d KB |
50 | getc(3), ferror(3) fread(3), scanf(3) |
51 | .SH STANDARDS | |
52 | The | |
53 | .I gets | |
54 | function is ANSI C compatible. |