title: Getting the words from a sentence and storing them in a vector of strings
body: <p>Alright, guys ... </p>
  
  <p>Here's my set that has all the letters. I'm defining a word as consisting of consecutive letters from the set. </p>
  
  <pre><code>const char LETTERS_ARR[] = {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
  const std::set&lt;char&gt; LETTERS_SET(LETTERS_ARR, LETTERS_ARR + sizeof(LETTERS_ARR)/sizeof(char));
  </code></pre>
  
  <p>I was hoping that this function would take in a string representing a sentence and return a vector of strings that are the individual words in the sentence.</p>
  
  <pre><code>std::vector&lt;std::string&gt; get_sntnc_wrds(std::string S) { 
      std::vector&lt;std::string&gt; retvec;
      std::string::iterator it = S.begin(); 
      while (it != S.end()) { 
          if (LETTERS_SET.count(*it) == 1) { 
              std::string str(1,*it);
              int k(0);
              while (((it+k+1) != S.end()) &amp;&amp; (LETTERS_SET.count(*(it+k+1) == 1))) { 
                  str.push_back(*(it + (++k)));
              }
              retvec.push_back(str);
              it += k;
          }
          else { 
              ++it;
          }
      }
      return retvec;
  } 
  </code></pre>
  
  <p>For instance, the following call should return a vector of the strings "Yo", "dawg", etc.</p>
  
  <pre><code>std::string mystring("Yo, dawg, I heard you life functions, so we put a function inside your function so you can derive while you derive.");
  std::vector&lt;std::string&gt; mystringvec = get_sntnc_wrds(mystring);
  </code></pre>
  
  <p>But everything isn't going as planned. I tried running my code and it was putting the entire sentence into the first and only element of the vector. My function is very messy code and perhaps you can help me come up with a simpler version. I don't expect you to be able to trace my thought process in my pitiful attempt at writing that function. </p>