move to compatibility library, make ANSI compliant, remove fgets(3)
[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.\"
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 21gets - get a line from stdin
2e146d0b 22.SH SYNOPSIS
8bdcef8d
KB
23.nf
24.ft B
25#include <stdio.h>
26
27char *gets(s)
28char *s;
29.ft R
30.SH DESCRIPTION
31.ft B
32This interface is obsoleted by fgets(3).
33As it makes no effort to avoid overwriting its buffer,
34it's a clear security problem.
2e146d0b 35.br
8bdcef8d
KB
36It is available from the compatibility library, libcompat.
37.ft R
2e146d0b 38.PP
8bdcef8d
KB
39The
40.I gets
41function reads characters from the input stream pointed to by
42.IR stdin ,
43into the array pointed to by
44.IR s ,
45until end-of-file is encountered or a new-line character is read.
46Any newline character is discarded, and a null character is written
47immediately after the last character read into the array.
2e146d0b 48.PP
8bdcef8d
KB
49The
50.I gets
51function returns
2e146d0b 52.I s
8bdcef8d
KB
53if successful.
54If end-of-file is encountered and no characters have been read into
55the array, the contents of the array remain unchanged and a null
56pointer is returned.
57If a read error occurrs during the operation, the array contents
58are indeterminate and a null pointer is returned.
2e146d0b 59.SH "SEE ALSO"
8bdcef8d
KB
60getc(3), ferror(3) fread(3), scanf(3)
61.SH STANDARDS
62The
63.I gets
64function is ANSI C compatible.