title: Why is the following C++ code printing only the first character?
body: <p>I am trying to convert a char string to a wchar string.</p>
  
  <p>In more detail: I am trying to convert a char[] to a wchar[] first and then append " 1" to that string and the print it.</p>
  
  <pre><code>char src[256] = "c:\\user";
  
  wchar_t temp_src[256];
  mbtowc(temp_src, src, 256);
  
  wchar_t path[256];
  
  StringCbPrintf(path, 256, _T("%s 1"), temp_src);
  wcout &lt;&lt; path;
  </code></pre>
  
  <p>But it prints just <code>c</code></p>
  
  <p>Is this the right way to convert from char to wchar? I have come to know of another way since. But I'd like to know why the above code works the way it does?</p>