Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

108 rindas
4.5KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>getc (The Red Hat newlib C Library)</title>
  7. <meta name="description" content="getc (The Red Hat newlib C Library)">
  8. <meta name="keywords" content="getc (The Red Hat newlib C Library)">
  9. <meta name="resource-type" content="document">
  10. <meta name="distribution" content="global">
  11. <meta name="Generator" content="makeinfo">
  12. <link href="index.html#Top" rel="start" title="Top">
  13. <link href="Document-Index.html#Document-Index" rel="index" title="Document Index">
  14. <link href="Document-Index.html#SEC_Contents" rel="contents" title="Table of Contents">
  15. <link href="Stdio.html#Stdio" rel="up" title="Stdio">
  16. <link href="getc_005funlocked.html#getc_005funlocked" rel="next" title="getc_unlocked">
  17. <link href="fwrite.html#fwrite" rel="prev" title="fwrite">
  18. <style type="text/css">
  19. <!--
  20. a.summary-letter {text-decoration: none}
  21. blockquote.indentedblock {margin-right: 0em}
  22. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  23. blockquote.smallquotation {font-size: smaller}
  24. div.display {margin-left: 3.2em}
  25. div.example {margin-left: 3.2em}
  26. div.lisp {margin-left: 3.2em}
  27. div.smalldisplay {margin-left: 3.2em}
  28. div.smallexample {margin-left: 3.2em}
  29. div.smalllisp {margin-left: 3.2em}
  30. kbd {font-style: oblique}
  31. pre.display {font-family: inherit}
  32. pre.format {font-family: inherit}
  33. pre.menu-comment {font-family: serif}
  34. pre.menu-preformatted {font-family: serif}
  35. pre.smalldisplay {font-family: inherit; font-size: smaller}
  36. pre.smallexample {font-size: smaller}
  37. pre.smallformat {font-family: inherit; font-size: smaller}
  38. pre.smalllisp {font-size: smaller}
  39. span.nolinebreak {white-space: nowrap}
  40. span.roman {font-family: initial; font-weight: normal}
  41. span.sansserif {font-family: sans-serif; font-weight: normal}
  42. ul.no-bullet {list-style: none}
  43. -->
  44. </style>
  45. </head>
  46. <body lang="en">
  47. <a name="getc"></a>
  48. <div class="header">
  49. <p>
  50. Next: <a href="getc_005funlocked.html#getc_005funlocked" accesskey="n" rel="next">getc_unlocked</a>, Previous: <a href="fwrite.html#fwrite" accesskey="p" rel="prev">fwrite</a>, Up: <a href="Stdio.html#Stdio" accesskey="u" rel="up">Stdio</a> &nbsp; [<a href="Document-Index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Document-Index.html#Document-Index" title="Index" rel="index">Index</a>]</p>
  51. </div>
  52. <hr>
  53. <a name="getc_002d_002d_002dread-a-character-_0028macro_0029"></a>
  54. <h3 class="section">4.33 <code>getc</code>&mdash;read a character (macro)</h3>
  55. <a name="index-getc"></a>
  56. <a name="index-_005fgetc_005fr"></a>
  57. <p><strong>Synopsis</strong>
  58. </p><div class="example">
  59. <pre class="example">#include &lt;stdio.h&gt;
  60. int getc(FILE *<var>fp</var>);
  61. #include &lt;stdio.h&gt;
  62. int _getc_r(struct _reent *<var>ptr</var>, FILE *<var>fp</var>);
  63. </pre></div>
  64. <p><strong>Description</strong><br>
  65. <code>getc</code> is a macro, defined in <code>stdio.h</code>. You can use <code>getc</code>
  66. to get the next single character from the file or stream
  67. identified by <var>fp</var>. As a side effect, <code>getc</code> advances the file&rsquo;s
  68. current position indicator.
  69. </p>
  70. <p>For a subroutine version of this macro, see <code>fgetc</code>.
  71. </p>
  72. <p>The <code>_getc_r</code> function is simply the reentrant version of <code>getc</code>
  73. which passes an additional reentrancy structure pointer argument: <var>ptr</var>.
  74. </p>
  75. <br>
  76. <p><strong>Returns</strong><br>
  77. The next character (read as an <code>unsigned char</code>, and cast to
  78. <code>int</code>), unless there is no more data, or the host system reports a
  79. read error; in either of these situations, <code>getc</code> returns <code>EOF</code>.
  80. </p>
  81. <p>You can distinguish the two situations that cause an <code>EOF</code> result by
  82. using the <code>ferror</code> and <code>feof</code> functions.
  83. </p>
  84. <br>
  85. <p><strong>Portability</strong><br>
  86. ANSI C requires <code>getc</code>; it suggests, but does not require, that
  87. <code>getc</code> be implemented as a macro. The standard explicitly permits
  88. macro implementations of <code>getc</code> to use the argument more than once;
  89. therefore, in a portable program, you should not use an expression
  90. with side effects as the <code>getc</code> argument.
  91. </p>
  92. <p>Supporting OS subroutines required: <code>close</code>, <code>fstat</code>, <code>isatty</code>,
  93. <code>lseek</code>, <code>read</code>, <code>sbrk</code>, <code>write</code>.
  94. </p>
  95. <br>
  96. </body>
  97. </html>