title: How to truncate a string array? C++
body: <p>Let's say I have a string array with 5 words and I want to only output the first 3 letters of each word. How do I go upon doing this? I know how to do it with one string but with an array of strings I get lost.</p>
  
  <p>This is how to do it with one string</p>
  
  <pre><code>std::string test = "hello";
  
  std::cout &lt;&lt; test &lt;&lt; std::endl;
  
  test = test.substr(0,3);
  
  std::cout &lt;&lt; test &lt;&lt; std::endl;
  </code></pre>
  
  <p>What I want to do is this</p>
  
  <pre><code>std::string test[5] = {"hello", "pumpkin", "friday", "snowboard", "snacks"};
  </code></pre>
  
  <p>I want to cout the first 3 letters of each word. I tried test[5] = test[5].substr(0,3); and that did not work.</p>