title: C++ replace all occurances of character in string
body: <p>I have a program in C++ in which all the input into the program has underscores('_') instead of spaces. I'm trying to replace all the underscores which spaces(' '). I tried using std::replace but I keep getting errors, I'm not sure where I'm getting it wrong.</p>
  
  <pre><code>int main()
  {   
      string j = "This_is_a_test";
  
      j = std::replace( j.begin(), j.end(), '_', ' ');
  
      // I'm trying to get: This is a test from 'j',  
  }
  </code></pre>
  
  <p>This is returning an error when I try compiling:</p>
  
  <blockquote>
    <p>conversion from <code>void' to non-scalar type</code>std::basic_string, std::allocator >' requested</p>
  </blockquote>