title: Indenting Paragraph With cout
body: <p>Given a string of unknown length, how can you output it using cout so that the entire string displays as an indented block of text on the console? (so that even if the string wraps to a new line, the second line would have the same level of indentation)</p>
  
  <p>Example:</p>
  
  <pre><code>cout &lt;&lt; "This is a short string that isn't indented." &lt;&lt; endl;
  cout &lt;&lt; /* Indenting Magic */ &lt;&lt; "This is a very long string that will wrap to the next line because it is a very long string that will wrap to the next line..." &lt;&lt; endl;
  </code></pre>
  
  <p>And the desired output:</p>
  
  <blockquote>
    <p>This is a short string that isn't indented.</p>
  
  <pre><code>    This is a very long string that will
      wrap to the next line because it is a
      very long string that will wrap to the
      next line...
  </code></pre>
  </blockquote>
  
  <p><strong>Edit:</strong> The homework assignment I'm working on is complete. The assignment has nothing to do with getting the output to format as in the above example, so I probably shouldn't have included the homework tag. This is just for my own enlightment.</p>
  
  <p>I know I could count through the characters in the string, see when I get to the end of a line, then spit out a newline and output -x- number of spaces each time. I'm interested to know if there is a simpler, idiomatic C++ way to accomplish the above.</p>