You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

getwchar.html 4.9KB

3 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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>getwchar (The Red Hat newlib C Library)</title>
  7. <meta name="description" content="getwchar (The Red Hat newlib C Library)">
  8. <meta name="keywords" content="getwchar (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="mktemp.html#mktemp" rel="next" title="mktemp">
  17. <link href="getw.html#getw" rel="prev" title="getw">
  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="getwchar"></a>
  48. <div class="header">
  49. <p>
  50. Next: <a href="mktemp.html#mktemp" accesskey="n" rel="next">mktemp</a>, Previous: <a href="getw.html#getw" accesskey="p" rel="prev">getw</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="getwchar_002c-getwchar_005funlocked_002d_002d_002dread-a-wide-character-from-standard-input"></a>
  54. <h3 class="section">4.41 <code>getwchar</code>, <code>getwchar_unlocked</code>&mdash;read a wide character from standard input</h3>
  55. <a name="index-getwchar"></a>
  56. <a name="index-getwchar_005funlocked"></a>
  57. <a name="index-_005fgetwchar_005fr"></a>
  58. <a name="index-_005fgetwchar_005funlocked_005fr"></a>
  59. <p><strong>Synopsis</strong>
  60. </p><div class="example">
  61. <pre class="example">#include &lt;wchar.h&gt;
  62. wint_t getwchar(void);
  63. #define _GNU_SOURCE
  64. #include &lt;wchar.h&gt;
  65. wint_t getwchar_unlocked(void);
  66. #include &lt;wchar.h&gt;
  67. wint_t _getwchar_r(struct _reent *<var>reent</var>);
  68. #include &lt;wchar.h&gt;
  69. wint_t _getwchar_unlocked_r(struct _reent *<var>reent</var>);
  70. </pre></div>
  71. <p><strong>Description</strong><br>
  72. <code>getwchar</code> function or macro is the wide character equivalent of
  73. the <code>getchar</code> function. You can use <code>getwchar</code> to get the next
  74. wide character from the standard input stream. As a side effect,
  75. <code>getwchar</code> advances the standard input&rsquo;s current position indicator.
  76. </p>
  77. <p><code>getwchar_unlocked</code> is a non-thread-safe version of <code>getwchar</code>.
  78. <code>getwchar_unlocked</code> may only safely be used within a scope
  79. protected by flockfile() (or ftrylockfile()) and funlockfile(). This
  80. function may safely be used in a multi-threaded program if and only
  81. if they are called while the invoking thread owns the (FILE *)
  82. object, as is the case after a successful call to the flockfile() or
  83. ftrylockfile() functions. If threads are disabled, then
  84. <code>getwchar_unlocked</code> is equivalent to <code>getwchar</code>.
  85. </p>
  86. <p>The alternate functions <code>_getwchar_r</code> and <code>_getwchar_unlocked_r</code> are
  87. reentrant versions of the above. The extra argument <var>reent</var> is a pointer to
  88. a reentrancy structure.
  89. </p>
  90. <br>
  91. <p><strong>Returns</strong><br>
  92. The next wide character cast to <code>wint_t</code>, unless there is no more
  93. data, or the host system reports a read error; in either of these
  94. situations, <code>getwchar</code> returns <code>WEOF</code>.
  95. </p>
  96. <p>You can distinguish the two situations that cause an <code>WEOF</code> result by
  97. using &lsquo;<code>ferror(stdin)</code>&rsquo; and &lsquo;<code>feof(stdin)</code>&rsquo;.
  98. </p>
  99. <br>
  100. <p><strong>Portability</strong><br>
  101. <code>getwchar</code> is required by C99.
  102. </p>
  103. <p><code>getwchar_unlocked</code> is a GNU extension.
  104. </p>
  105. <br>
  106. </body>
  107. </html>