title: Converting from LPCWSTR to LPCSTR
body: <p>I'm having trouble trying to cast a LPCWSTR to an LPCSTR.</p>
  
  <p><strong>Some Background</strong></p>
  
  <p>I am programming a VC++ 2010 application, and have already run into the situation where I had to convert from type System::String^ to std::string. I used this code to do so:</p>
  
  <pre><code>private: std::string toss(System::String^ s)
      {
          msclr::interop::marshal_context context;
          return context.marshal_as&lt;std::string&gt;(s);
      }
  </code></pre>
  
  <p>Doing so, I thought I would solve all my problems. I was wrong. From this, I need to cast a std::string as an LPCSTR, to use with some Windows API.</p>
  
  <p>After reading some of the existing questions on SO, I feel like I am stuck. I was told to use:</p>
  
  <pre><code>LPCSTR str = existingstr.c_str();
  </code></pre>
  
  <p>When I use this, however, I am given the error: <strong>Cannot convert from LPCWSTR to LPCSTR</strong></p>
  
  <p>Does anyone have a better idea of what I should do in this specific case, or how I can convert from LPCWSTR to LPCSTR?</p>
  
  <p>Thanks in advance.</p>