update for vnode interface
[unix-history] / usr / src / lib / libc / stdio / fgets.3
CommitLineData
952018c5
KB
1.\" Copyright (c) 1989 The Regents of the University of California.
2.\" All rights reserved.
2e146d0b 3.\"
952018c5
KB
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.\" @(#)fgets.3 6.3 (Berkeley) %G%
17.\"
18.TH FGETS 3 ""
2e146d0b
KM
19.AT 3
20.SH NAME
952018c5 21fgets - get a line from a stream
2e146d0b 22.SH SYNOPSIS
952018c5 23.nf
2e146d0b 24.B #include <stdio.h>
952018c5 25
2e146d0b 26.B char *fgets(s, n, stream)
2e146d0b 27.B char *s;
952018c5
KB
28.B int n;
29.B FILE *stream;
30.fi
2e146d0b 31.SH DESCRIPTION
952018c5
KB
32The
33.I fgets
34function reads at most one less than the number of characters specified
35by
36.I n
37from the stream pointed to by
2e146d0b 38.I stream
952018c5 39into the array pointed to by
2e146d0b 40.IR s .
952018c5
KB
41No additional characters are read after a new-line character
42(which is retained) or after end-of-file.
43A null character is written immediately after the last character
44read into the array.
45.PP
46The
47.I fgets
48function returns
2e146d0b 49.I s
952018c5
KB
50if successful.
51If end-of-file is encountered and no characters have been read
52into the array, the contents of the array remain unchanged and
53a null pointer is returned.
54If a read error occurs during the operation, the array contents
55are indeterminate and a null pointer is returned.
2e146d0b 56.SH "SEE ALSO"
952018c5
KB
57getc(3), ferror(3) fread(3), scanf(3)
58.SH STANDARDS
59The
2e146d0b 60.I fgets
952018c5 61function is ANSI C compatible.