title: How to get rid of string of characters in CString in C++
body: <p>The CString type I am talking about is <a href="http://msdn.microsoft.com/en-us/library/aa300688%28v=vs.60%29" rel="nofollow">microsoft's</a>.</p>
  
  <p>I've attempted two methods;</p>
  
  <p>Method 1) using the Remove() and Replace() function found on msdn website, and Visual c++ says <code>Error:argument of type "const char*" is incompatible with argument of type "wchar_t"</code></p>
  
  <p>Specifically my code is:</p>
  
  <pre><code>#include &lt;cstring&gt;
  
  CString sTmp= sBody.Mid(nOffset);
  CString sFooter= L"https://" + sTmp.Mid(0, nEnd );
  sFooter.Remove("amp;");
  </code></pre>
  
  <p>And I don't want to remove a single character at a time because it will get rid of other 'a's.</p>
  
  <p>For some reason, when I convert sFooter to a std::string, random "amp;"s appear in the string that shouldn't be there...</p>
  
  <p>I am converting sFooter to a std::string like this:</p>
  
  <pre><code>CT2CA p (sFooter);
  string str (p);
  </code></pre>
  
  <p>Method 2) Converting the CString to std::string, then using erase() and remove() to get rid of the "amp;"s</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;algorithm&gt;
  
  sFooter2.erase(std::remove(sFooter2.begin(), sFooter2.end(), "amp;"), sFooter2.end());
  </code></pre>
  
  <p>But Visual studio's output shows this: <a href="http://pastebin.com/s6tXQ48N" rel="nofollow">http://pastebin.com/s6tXQ48N</a></p>