title: How can I split a string by a delimiter into an array?
body: <p>I am new to programming.  I have been trying to write a function in C++ that explodes the contents of a string into a string array at a given parameter, example:</p>
  
  <pre><code>string str = "___this_ is__ th_e str__ing we__ will use__";
  </code></pre>
  
  <p>should return string array:</p>
  
  <pre><code>cout &lt;&lt; stringArray[0]; // 'this'
  cout &lt;&lt; stringArray[1]; // ' is'
  cout &lt;&lt; stringArray[2]; // ' th'
  cout &lt;&lt; stringArray[3]; // 'e str'
  cout &lt;&lt; stringArray[4]; // 'ing we'
  cout &lt;&lt; stringArray[5]; // ' will use'
  </code></pre>
  
  <p>I can tokenize the string just fine, but the hardest part for me is how can i specify the number of elements in stringArray before assigning it the current string toke and also how to return stringArray from the function.</p>
  
  <p>Would someone show me how to write the function?</p>
  
  <p><strong>Edit1:</strong>  I don't necessarily need the results to been in string array just any container that i can call as a regular variable with some sort of indexing.</p>