466
|
1 <refentry id="gets">
|
|
2 <refnamediv>
|
570
|
3 <refname>Gets</refname>
|
|
4 <refname>Fgets</refname>
|
|
5 <refpurpose>input a string</refpurpose>
|
466
|
6 </refnamediv>
|
|
7
|
|
8 <refsynopsisdiv>
|
|
9 <funcsynopsis>
|
468
|
10 <funcsynopsisinfo>
|
|
11 #include <stdio.h>
|
|
12 </funcsynopsisinfo>
|
466
|
13 <funcprototype>
|
570
|
14 <funcdef>char *<function>gets</function></funcdef>
|
|
15 <paramdef>char *<parameter>s</parameter></paramdef>
|
|
16 </funcprototype>
|
|
17
|
|
18 <funcprototype>
|
|
19 <funcdef>char *<function>fgets</function></funcdef>
|
|
20 <paramdef>char *<parameter>s</parameter></paramdef>
|
|
21 <paramdef>int <parameter>n</parameter></paramdef>
|
|
22 <paramdef>FILE *<parameter>fp</parameter></paramdef>
|
466
|
23 </funcprototype>
|
|
24 </funcsynopsis>
|
|
25
|
|
26 </refsynopsisdiv>
|
|
27
|
|
28 <refsect1><title>Description</title>
|
|
29 <para>
|
598
|
30 Fgets reads characters from the file "fp" and places them in
|
|
31 the buffer pointed to by "s" up to a carriage return ('\n') but
|
|
32 not more than "n" - 1 characters. A null character is appended
|
|
33 to the end of the string.
|
|
34 </para>
|
|
35 <para>
|
|
36 Gets is similar to fgets, but gets is applied to "stdin" and no
|
|
37 maximum is stipulated and '\n' is replaced by a null.
|
|
38 </para>
|
|
39 <para>
|
|
40 Both functions return their first arguments.
|
466
|
41 </para>
|
|
42 </refsect1>
|
542
|
43
|
552
|
44 <refsect1><title>Caveats</title>
|
|
45 <para>
|
|
46 The different treatment of the "\n" by these functions is
|
|
47 retained here for portability reasons.
|
|
48 </para>
|
|
49 </refsect1>
|
|
50
|
|
51 <refsect1><title>Diagnostics</title>
|
|
52 <para>
|
|
53 Both functions return NULL on end-of-file or error.
|
|
54 </para>
|
|
55 </refsect1>
|
|
56
|
542
|
57 <refsect1><title>See Also</title>
|
|
58 <para>
|
|
59 <link linkend="puts">puts()</link>,
|
|
60 <link linkend="getc">getc()</link>,
|
|
61 <link linkend="scanf">scanf()</link>,
|
|
62 <link linkend="fread">fread()</link>
|
|
63 </para>
|
|
64 </refsect1>
|
|
65
|
466
|
66 </refentry>
|