title: C++ function split string into words
body: <p>im trying to write a function in c++ that splits my string test into separate words in an array. i cant seem to the stuff in loop right... anyone got any ideas? it should print "this"</p>
  
  <pre><code>void app::split() {
  
      string test = "this is my testing string.";
  
      char* tempLine = new char[test.size() + 1];
      strcpy(tempLine, test.c_str());
  
      char* singleWord;
  
      for (int i = 0; i &lt; sizeof(tempLine); i++) {
  
          if (tempLine[i] == ' ') {
              words[wordCount] = singleWord;
              delete[]singleWord;
          }
  
              else {
              singleWord[i] = tempLine[i];
              wordCount++;
  
              }
  
      }
  
      cout &lt;&lt; words[0];
      delete[]tempLine;
  
  
  }
  </code></pre>