C++ - read ANSI encoded text as wide character string
<p>My aim is to read ANSI encoded texts. But for some reasons I'm using fgetws() (not fgets) function and of course file is opened in binary mode. Here is the short code which demonstrates my problem</p>

<pre><code>  bool testfunc(wchar_t path[])
  {
     wchar_t buffer[10];

     if( FILE * fr=_wfopen(path,L"rb") )
     {
        fgetws(buffer,sizeof(buffer),fr);
        fclose(fr);
        return true;
     }
     else return false;
  }
</code></pre>

<p>when I call this function and pass ANSI encoded text file path as an argument, there arises Access Violation error in run time. It seems that the error occurs when the text size is large enough.  I can not figure out where the problem is.</p>
