title: Converting string to LPCTSTR
body: <p>I encountered a problem during writting my code. I use a function which take as an argument object which type is LPCSTR. The object declaration looks like shown  below:
  LPCTSTR lpFileName; 
  Firstly, I used defined variable, which was futher assign to lpFileName like this:</p>
  
  <pre><code>#define COM_NR L"COM3"
  lpFileName = COM_NR
  </code></pre>
  
  <p>Using this manner, I could easily pass lpFileName argument to the function. Anyway, i had to changed the way of defining my port number. Currently i read  text from *.txt file and save it as string variable e.g "COM3" or "COM10". The main problem is to convert string to LPCSTR properly. I found good solution but finally it doesn't seem working properly. My code looks like this:</p>
  
  <pre><code>string temp;
  \\code that fill temp\\
  wstring ws;
  ws.assign(temp.begin(),temp.end());
  </code></pre>
  
  <p>I thought that conversion went correctly, maybe it did and I don't get it because when i print few things it makes me to wonder why it doesn't work as i want:
  cout temp_cstr(): COM3
  cout LCOM3: 0x40e586
  cout ws.c_str(): 0x8b49b2c</p>
  
  <p>Why LCOM3 and ws.c_str() doesn't contain the same? When i pass lpFileName = ws.c_str() to my function, it works uncorretly. On the other hand, passing lpFileName = L"COM3" gives success.
  I code using cpp, and IDE is QtCreator</p>