title: Making a WCHAR null terminated
body: <p>I've got this</p>
  
  <p>WCHAR  fileName[1];  </p>
  
  <p>as a returned value from a function (it's a sys 32 function so I am not able to change the returned type).  I need to make fileName to be null terminated so I am trying to append '\0' to it, but nothing seems to work.</p>
  
  <p>Once I get a null terminated WCHAR I will need to pass it to another sys 32 function so I need it to stay as WCHAR.</p>
  
  <p>Could anyone give me any suggestion please?</p>
  
  <p>================================================</p>
  
  <p>Thanks a lot for all your help.  Looks like my problem has to do with more than missing a null terminated string.</p>
  
  <p>//This works:</p>
  
  <pre><code>WCHAR szPath1[50] = L"\\Invalid2.txt.txt";
      dwResult = FbwfCommitFile(szDrive, pPath1); //Successful
  </code></pre>
  
  <p>//This does not:</p>
  
  <pre><code>std::wstring l_fn(L"\\");  
      //Because Cache_detail-&gt;fileName is \Invalid2.txt.txt and I need two
  l_fn.append(Cache_detail-&gt;fileName);
  l_fn += L""; //To ensure null terminated
  fprintf(output, "l_fn.c_str: %ls\n", l_fn.c_str()); //Prints "\\Invalid2.txt.txt"
  
      iCommitErr = FbwfCommitFile(L"C:", (WCHAR*)l_fn.c_str()); //Unsuccessful
  </code></pre>
  
  <p>//Then when I do a comparison on these two they are unequal.</p>
  
  <pre><code>int iCompareResult = l_fn.compare(pPath1);  // returns -1
  </code></pre>
  
  <p>So I need to figure out how these two ended up to be different.</p>
  
  <p>Thanks a lot!</p>