title: How do I split a user-defined sentence into words in C++ using substr and find?
body: <p>I used this function but it is wrong.</p>
  
  <pre><code>for (int i=0; i&lt;sen.length(); i++) {
      if (sen.find (' ') != string::npos) {
          string new = sen.substr(0,i);
      }
  cout &lt;&lt; "Substrings:" &lt;&lt; new &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Thank you! Any kind of help is appreciated!</p>