Inserting a newline near the end of a std::string : <p>I'm struggling with trying to implement a C++ code solution that will allow me to insert a newline (i.e. a string literal <code>'\n'</code>) <em>towards the end</em> of a <code>std::string</code>, and <strong>not</strong> at the very end as most implementations show.</p>

<p>For example, I want to insert a <code>'\n'</code> just <code>-1</code> characters before the very end itself. So if the string was 100 characters long (poor analogy I know), then I'd like to insert the string literal at the 99th character in a clean, easily readable manner.</p>

<p>Thanks!</p>
