| <html lang="en"> |
| <head> |
| <title>getchar - Untitled</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Untitled"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Stdio.html#Stdio" title="Stdio"> |
| <link rel="prev" href="getc_005funlocked.html#getc_005funlocked" title="getc_unlocked"> |
| <link rel="next" href="getchar_005funlocked.html#getchar_005funlocked" title="getchar_unlocked"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="getchar"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="getchar_005funlocked.html#getchar_005funlocked">getchar_unlocked</a>, |
| Previous: <a rel="previous" accesskey="p" href="getc_005funlocked.html#getc_005funlocked">getc_unlocked</a>, |
| Up: <a rel="up" accesskey="u" href="Stdio.html#Stdio">Stdio</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">4.34 <code>getchar</code>—read a character (macro)</h3> |
| |
| <p><a name="index-getchar-219"></a><a name="index-g_t_005fgetchar_005fr-220"></a><strong>Synopsis</strong> |
| <pre class="example"> #include <stdio.h> |
| int getchar(void); |
| |
| int _getchar_r(struct _reent *<var>reent</var>); |
| |
| </pre> |
| <p><strong>Description</strong><br> |
| <code>getchar</code> is a macro, defined in <code>stdio.h</code>. You can use <code>getchar</code> |
| to get the next single character from the standard input stream. |
| As a side effect, <code>getchar</code> advances the standard input's |
| current position indicator. |
| |
| <p>The alternate function <code>_getchar_r</code> is a reentrant version. The |
| extra argument <var>reent</var> is a pointer to a reentrancy structure. |
| |
| <p><br> |
| <strong>Returns</strong><br> |
| The next character (read as an <code>unsigned char</code>, and cast to |
| <code>int</code>), unless there is no more data, or the host system reports a |
| read error; in either of these situations, <code>getchar</code> returns <code>EOF</code>. |
| |
| <p>You can distinguish the two situations that cause an <code>EOF</code> result by |
| using `<code>ferror(stdin)</code>' and `<code>feof(stdin)</code>'. |
| |
| <p><br> |
| <strong>Portability</strong><br> |
| ANSI C requires <code>getchar</code>; it suggests, but does not require, that |
| <code>getchar</code> be implemented as a macro. |
| |
| <p>Supporting OS subroutines required: <code>close</code>, <code>fstat</code>, <code>isatty</code>, |
| <code>lseek</code>, <code>read</code>, <code>sbrk</code>, <code>write</code>. |
| |
| <p><br> |
| |
| </body></html> |
| |