view docs/ccguide/gets.refentry @ 1331:0a3500c747de

Fixed ANOTHER bug
author boisy
date Sun, 07 Sep 2003 00:53:51 +0000
parents a74b8d8c28db
children
line wrap: on
line source

<refentry id="gets">
<refnamediv>
<refname>Gets</refname>
<refname>Fgets</refname>
<refpurpose>input a string</refpurpose>
</refnamediv>

<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>
#include &lt;stdio.h&gt;
</funcsynopsisinfo>
<funcprototype>
  <funcdef>char *<function>gets</function></funcdef>
  <paramdef>char *<parameter>s</parameter></paramdef>
</funcprototype>

<funcprototype>
  <funcdef>char *<function>fgets</function></funcdef>
  <paramdef>char *<parameter>s</parameter></paramdef>
  <paramdef>int <parameter>n</parameter></paramdef>
  <paramdef>FILE *<parameter>fp</parameter></paramdef>
</funcprototype>
</funcsynopsis>

</refsynopsisdiv>

<refsect1><title>Description</title>
<para>
Fgets reads characters from the file "fp" and places them in
the buffer pointed to by "s" up to a carriage return ('\n') but
not more than "n" - 1 characters. A null character is appended
to the end of the string.
</para>
<para>
Gets is similar to fgets, but gets is applied to "stdin" and no
maximum is stipulated and '\n' is replaced by a null.
</para>
<para>
Both functions return their first arguments.
</para>
</refsect1>

<refsect1><title>Caveats</title>
<para>
The different treatment of the "\n" by these functions is
retained here for portability reasons.
</para>
</refsect1>

<refsect1><title>Diagnostics</title>
<para>
Both functions return NULL on end-of-file or error.
</para>
</refsect1>

<refsect1><title>See Also</title>
<para>
<link linkend="puts">puts()</link>,
<link linkend="getc">getc()</link>,
<link linkend="scanf">scanf()</link>,
<link linkend="fread">fread()</link>
</para>
</refsect1>

</refentry>