title: find all permutations of a string in c++
body: <p>The following is a code to print all permutations of a given string. The code compiles but does not print anything.</p>
  
  <pre><code>using namespace std;
  
  void RecPermute(string, string);
  
  int main() {
      RecPermute("", "abc");
      return 0;
  }
  
  void RecPermute(string soFar, string rest) {
      if (rest == " ") {
          cout &lt;&lt; soFar &lt;&lt; endl;
      } else {
          for(int i=0; i&lt;rest.length(); i++) {
              string next = soFar + rest[i];
              string remaining = rest.substr(0, i) + rest.substr(i+1);
              RecPermute(next, remaining);
      }
      }
  }
  </code></pre>
  
  <p>What needs to be fixed?</p>