title: How do I use MultiByteToWideChar?
body: <p>I want to convert a normal <code>string</code> to a <code>wstring</code>. For this, I am trying to use the Windows API function <a href="https://docs.microsoft.com/en-us/windows/desktop/api/stringapiset/nf-stringapiset-multibytetowidechar" rel="noreferrer"><code>MultiByteToWideChar</code></a>.
  But it does not work for me.</p>
  
  <p>Here is what I have done:</p>
  
  <pre><code>string x = "This is c++ not java";
  wstring Wstring;
  MultiByteToWideChar( CP_UTF8 , 0 , x.c_str() , x.size() , &amp;Wstring , 0 ); 
  </code></pre>
  
  <p>The last line produces the compiler error:</p>
  
  <pre class="lang-none prettyprint-override"><code>'MultiByteToWideChar' : cannot convert parameter 5 from 'std::wstring *' to 'LPWSTR'
  </code></pre>
  
  <p>How do I fix this error?</p>
  
  <p>Also, what should be the value of the argument <code>cchWideChar</code>? Is 0 okay?</p>