title: I am getting replace was not declared in this scope
body: <p>This is a function I am writing that switches the characters  of a string, but I am getting "replace was not declared in this scope".</p>
  
  <pre><code>#include &lt;string&gt;
  
  using namespace std;
  
  string rs(string j)
  {
      srand(time(NULL));
  
      int len = j.size();
      int ran1 = rand() % len;
  
      srand(time(NULL) + 1);
  
      int ran2 = rand() % len;
  
      replace(j, ran1, ran2);
  
      cout &lt;&lt; j &lt;&lt; endl;
  
      return j;
  }
  </code></pre>
  
  <p>Obviously I have something wrong with the function.  Any help is appreciated.</p>