summaryrefslogtreecommitdiff
path: root/devdocs/c/io%2Fungetwc.html
blob: 88d39fd77819c39c32cad91b9a94dc017225852d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    <h1 id="firstHeading" class="firstHeading">ungetwc</h1>            <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;wchar.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td> <pre data-language="c">wint_t ungetwc( wint_t ch, FILE *stream );</pre>
</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> </td> </tr>  </table> <p>If <code>ch</code> does not equal <code>WEOF</code>, pushes the wide character <code>ch</code> into the input buffer associated with the stream <code>stream</code> in such a manner that subsequent read operation from <code>stream</code> will retrieve that wide character. The external device associated with the stream is not modified.</p>
<p>Stream repositioning operations <code><a href="fseek" title="c/io/fseek">fseek</a></code>, <code><a href="fsetpos" title="c/io/fsetpos">fsetpos</a></code>, and <code><a href="rewind" title="c/io/rewind">rewind</a></code> discard the effects of <code>ungetwc</code>.</p>
<p>If <code>ungetwc</code> is called more than once without an intervening read or repositioning, it may fail (in other words, a pushback buffer of size 1 is guaranteed, but any larger buffer is implementation-defined). If multiple successful <code>ungetwc</code> were performed, read operations retrieve the pushed-back wide characters in reverse order of <code>ungetwc</code></p>
<p>If <code>ch</code> equals <code>WEOF</code>, the operation fails and the stream is not affected.</p>
<p>A successful call to <code>ungetwc</code> clears the end of file status flag <code><a href="feof" title="c/io/feof">feof</a></code>.</p>
<p>A successful call to <code>ungetwc</code> on a stream (whether text or binary) modifies the stream position indicator in unspecified manner but guarantees that after all pushed-back wide characters are retrieved with a read operation, the stream position indicator is equal to its value before <code>ungetwc</code>.</p>
<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> ch </td> <td> - </td> <td> wide character to be put back </td>
</tr> <tr class="t-par"> <td> stream </td> <td> - </td> <td> file stream to put the wide character back to </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> <p>On success <code>ch</code> is returned.</p>
<p>On failure <code>WEOF</code> is returned and the given stream remains unchanged.</p>
<h3 id="References"> References</h3>  <ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul><li> 7.29.3.10 The ungetwc function (p: 425-426) </li></ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul><li> 7.24.3.10 The ungetwc function (p: 370-371) </li></ul>
</ul>      <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="ungetc" title="c/io/ungetc"> <span class="t-lines"><span>ungetc</span></span></a></div> </td> <td> puts a character back into a file stream <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="fgetwc" title="c/io/fgetwc"> <span class="t-lines"><span>fgetwc</span><span>getwc</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div> </td> <td> gets a wide character from a file stream <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/io/c/ungetwc" title="cpp/io/c/ungetwc">C++ documentation</a></span> for <code>ungetwc</code> </td>
</tr> </table>           <div class="_attribution">
  <p class="_attribution-p">
    &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
    <a href="https://en.cppreference.com/w/c/io/ungetwc" class="_attribution-link">https://en.cppreference.com/w/c/io/ungetwc</a>
  </p>
</div>