title: Convert char[] array to LPTSTR in vc++
body: <p>I want to use the Win API  <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx" rel="nofollow">CreateProcess</a> for which accepts 2nd parameter as "LPTSTR".</p>
  
  <p>But I've the path to my exe in a char array. My VS2013 project (static library) is Unicode  encoding type.
  Code snippert below.
   IN this line </p>
  
  <blockquote>
    <p>"appPath = (LPTSTR)TestEXEPath;"</p>
  </blockquote>
  
  <p>of the below code snippet where the type cast is happening, I see that the characters in "appPath" gets converted to some junk characters whereas the RHS of this expression "TestEXEPath" does have valid characters. 
  However tehre is no compilation error here. It is at run time this characters get corrupted in "appPath". </p>
  
  <p>I know this typecast is creating this problem. But how do I solve this, how do I type cast this char array to LPTSTR typr which is needed by "CreateProcess() API.</p>
  
  <p>Or is there any better way of doing this so as to avoid the char array itself.</p>
  
  <pre><code>LPTSTR  appPath;
  char cwd[_MAX_PATH];
  getcwd(cwd, _MAX_PATH);
  char TestEXEPath[_MAX_PATH];
  strcpy(TestEXEPath, cwd);
  
  strcat(TestEXEPath, "\\pwrtest.exe /sleep /c:1");
  
  appPath = (LPTSTR)TestEXEPath; // The characters in this gets converted to some junk characters.
  .......................
  ......................
  
  CreateProcess(NULL, appPath, NULL, NULL, FALSE, 0, NULL, workingDir, &amp;sI, &amp;pI))
  </code></pre>