title: How to replace one character at a specific index in a string
body: <p>I have a program which takes in a string as a command line argument. I then want to go into this string and replace one character with another at a specific index. So for a more concrete example, this is what I have and what I want to do:</p>
  
  <pre><code>string input(argv[2]); //lets say I run with ./Prog x bbbbbbb
  //I want to do this
  input.at(2) = "a"; //obviously this doesn't work
  </code></pre>
  
  <p>When I try <code>input.insert(2,a);</code>, and <code>cout &lt;&lt; input</code> I get <code>bb$bbbbb</code> followed by a seg fault message on the next line. I initially thought I could insert at 2 and erase at 3 to replace the 3rd b with an a, but the seg fault ruins this for me. So is there any other way I can do this, or help me understand why I'm getting a seg fault?</p>
  
  <p>edit: the seg fault was something else, but still I'm getting $ when attempting to input an a</p>