gets.html

来自「unix 下的C开发手册,还用详细的例程。」· HTML 代码 · 共 102 行

HTML
102
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>gets</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_731">&nbsp;</a>NAME</h4><blockquote>gets - get a string from a <i>stdin</i> stream</blockquote><h4><a name = "tag_000_005_732">&nbsp;</a>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="stdio.h.html">stdio.h</a>&gt;char *gets(char *<i>s</i>);</code></pre></blockquote><h4><a name = "tag_000_005_733">&nbsp;</a>DESCRIPTION</h4><blockquote>The<i>gets()</i>function reads bytes from the standard input stream,<i><a href="stdin.html">stdin</a></i>,into the array pointed to by<i>s</i>,until a newline is reador an end-of-file condition is encountered.Any newline is discardedand a null byte is placed immediately after the lastbyte read into the array.<p>The<i>gets()</i>function may mark the<i>st_atime</i>field of the file associated with<i>stream</i>for update.  The<i>st_atime</i>field will be marked for update by the first successful executionof<i><a href="fgetc.html">fgetc()</a></i>,<i><a href="fgets.html">fgets()</a></i>,<i><a href="fread.html">fread()</a></i>,<i><a href="getc.html">getc()</a></i>,<i><a href="getchar.html">getchar()</a></i>,<i>gets()</i>,<i><a href="fscanf.html">fscanf()</a></i>or<i><a href="scanf.html">scanf()</a></i>using<i>stream</i>that returns data not supplied by a prior call to<i><a href="ungetc.html">ungetc()</a></i>.</blockquote><h4><a name = "tag_000_005_734">&nbsp;</a>RETURN VALUE</h4><blockquote>Upon successful completion,<i>gets()</i>returns<i>s</i>.If the stream is at end-of-file, the end-of-file indicator forthe stream is set and<i>gets()</i>returns a null pointer.If a read error occurs, the error indicator for the stream is set,<i>gets()</i>returns a null pointer and sets<i>errno</i>to indicate the error.</blockquote><h4><a name = "tag_000_005_735">&nbsp;</a>ERRORS</h4><blockquote>Refer to<i><a href="fgetc.html">fgetc()</a></i>.</blockquote><h4><a name = "tag_000_005_736">&nbsp;</a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_737">&nbsp;</a>APPLICATION USAGE</h4><blockquote>Reading a line that overflows the array pointed to by<i>s</i>causes undefined results.  The use of<i><a href="fgets.html">fgets()</a></i>is recommended.</blockquote><h4><a name = "tag_000_005_738">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_739">&nbsp;</a>SEE ALSO</h4><blockquote><i><a href="feof.html">feof()</a></i>,<i><a href="ferror.html">ferror()</a></i>,<i><a href="fgets.html">fgets()</a></i>,<i><a href="stdio.h.html">&lt;stdio.h&gt;</a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from Issue 1 of the SVID.</blockquote><hr size=2 noshade><center><font size=2>UNIX &reg; is a registered Trademark of The Open Group.<br>Copyright &copy; 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?