title: Simple std::string replace in C++
body: <p>I am using the following code for replacing special characters in a <code>system date</code> format in Windows OS.</p>
  
  <p>But I can only replace one character.</p>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main ()
  {
      string str("10/16/13");
      string str2("/");
      str.replace(str.find(str2),str2.length(),"-");
      cout &lt;&lt; str &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>10-16/13
  </code></pre>