title: Replace a character/sequence of characters in a C++ std::string with another sequence of characters
body: <p>I want to replace all occurrences of <code>&amp;</code> in my <code>std::string</code> with <code>&amp;amp;</code>. Here, is the code snippet 
  <a href="http://ide.geeksforgeeks.org/tX7ki6" rel="nofollow noreferrer">codelink</a></p>
  
  <pre><code>#include &lt;algorithm&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  int main()
  {
      std::string st = "hello guys how are you &amp; so good &amp; that &amp;";
      std::replace(st.begin(), st.end(), "&amp;", "&amp;amp;");
      std::cout &lt;&lt; "str is" &lt;&lt; st;
      return 1;
  }
  </code></pre>
  
  <p>It shows error that std::replace can't replace string, but it only works with characters. 
  <strong>I know i can still have a logic to get my work done, but is there any clean C++ way of doing this ? Is there any inbuilt function ?</strong></p>