Converting string to wchar_t (wide character) C++
<p>I want to know how I can convert <code>string str = "whatever"</code> to <code>wchar_t</code> so that the string can be stored as <code>wchar_t chResponse[] = ...(converted from string)..</code></p>

<p>I am trying the following code:</p>

<pre><code>string str = "whatever";
std::wstring_convert&lt;std::codecvt_utf8&lt;wchar_t&gt;&gt; utf8conv;
auto w_result = utf8conv.from_bytes(str); // convert utf8 to wchar_t
wchar_t chResponse[] = w_result;
</code></pre>

<p>Its giving me this error: </p>

<pre><code>error C2075: 'chResponse' : array initialization needs curly braces
</code></pre>
