Commit | Line | Data |
---|---|---|
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 | 21 | fgets - 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 |
32 | The |
33 | .I fgets | |
34 | function reads at most one less than the number of characters specified | |
35 | by | |
36 | .I n | |
37 | from the stream pointed to by | |
2e146d0b | 38 | .I stream |
952018c5 | 39 | into the array pointed to by |
2e146d0b | 40 | .IR s . |
952018c5 KB |
41 | No additional characters are read after a new-line character |
42 | (which is retained) or after end-of-file. | |
43 | A null character is written immediately after the last character | |
44 | read into the array. | |
45 | .PP | |
46 | The | |
47 | .I fgets | |
48 | function returns | |
2e146d0b | 49 | .I s |
952018c5 KB |
50 | if successful. |
51 | If end-of-file is encountered and no characters have been read | |
52 | into the array, the contents of the array remain unchanged and | |
53 | a null pointer is returned. | |
54 | If a read error occurs during the operation, the array contents | |
55 | are indeterminate and a null pointer is returned. | |
2e146d0b | 56 | .SH "SEE ALSO" |
952018c5 KB |
57 | getc(3), ferror(3) fread(3), scanf(3) |
58 | .SH STANDARDS | |
59 | The | |
2e146d0b | 60 | .I fgets |
952018c5 | 61 | function is ANSI C compatible. |