date and time created 91/03/06 18:09:53 by bostic
[unix-history] / usr / src / lib / libc / stdio / gets.3
CommitLineData
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 11gets - get a line from stdin
2e146d0b 12.SH SYNOPSIS
8bdcef8d
KB
13.nf
14.ft B
15#include <stdio.h>
16
17char *gets(s)
18char *s;
19.ft R
20.SH DESCRIPTION
21.ft B
22This interface is obsoleted by fgets(3).
23As it makes no effort to avoid overwriting its buffer,
24it's a clear security problem.
2e146d0b 25.br
8bdcef8d
KB
26It is available from the compatibility library, libcompat.
27.ft R
2e146d0b 28.PP
8bdcef8d
KB
29The
30.I gets
31function reads characters from the input stream pointed to by
32.IR stdin ,
33into the array pointed to by
34.IR s ,
35until end-of-file is encountered or a new-line character is read.
36Any newline character is discarded, and a null character is written
37immediately after the last character read into the array.
2e146d0b 38.PP
8bdcef8d
KB
39The
40.I gets
41function returns
2e146d0b 42.I s
8bdcef8d
KB
43if successful.
44If end-of-file is encountered and no characters have been read into
45the array, the contents of the array remain unchanged and a null
46pointer is returned.
47If a read error occurrs during the operation, the array contents
48are indeterminate and a null pointer is returned.
2e146d0b 49.SH "SEE ALSO"
8bdcef8d
KB
50getc(3), ferror(3) fread(3), scanf(3)
51.SH STANDARDS
52The
53.I gets
54function is ANSI C compatible.