Read every word in a string C++
<p>I am trying to read every word a string. I want a string to go in and the first word to come out, then I'll process it, then the second, and so on. But the internet isn't helping me, I know it's probably right under my nose but I can't figure it out!</p>

<pre><code>string lex(string filecontent) {

string t = filecontent;
getline(cin, t);

istringstream iss(t);
string word;

while (iss &gt;&gt; word) {
    return word;
}

}
int main() {
    string data = load_file(); // Returns a string of words
    cout &lt;&lt; data;
    cout &lt;&lt; lex(data);
    getchar();
}
</code></pre>

<p>Right now this works... sort of it prints out a lot of random gibberish and crazy characters, The file I'm reading's output is ok I check this at cout &lt;&lt; data and it is what I expect. Any ideas?</p>