title: fgetwc EOF loop test fails, but 65535 OK
body: <p>VS10 &amp; MCBS:</p>
  
  <p>For this I have created a file called <em>c:\eoftest</em> containing the text <em>"test"</em>. The value of ch on the 5th pass in the following code is 65535 returned by fgetwc, but it does not equate to EOF, which we all know is defined in stdio.h as (-1):</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;windows.h&gt;
  
  int main()
  {
      int ch;
      FILE *stream = NULL;
      wchar_t buf[5];
      memset (buf, '\0', sizeof(buf));
      stream = _wfopen(L"C:\\eoftest.txt", L"r");
  
              for (int i = 0; (i  &lt; (sizeof(buf) - 1) &amp;&amp; ((ch = fgetwc(stream)) != EOF) &amp;&amp; (ch != '\0')); i++) //we are reading so last null condition mandatory
              {
              ungetwc(ch, stream);
              buf[i] = (wchar_t)(ch = fgetwc(stream));
              }
  }
  </code></pre>
  
  <p>Replacing the condition (sic) with <code>(ch = fgetwc(stream)) != 65535)</code> works in this case, but what is not done to ensure the EOF test can succeed?</p>