Tokenizing a String in C++

Hi,
I am trying to write a function that cuts a sentence to its words. And print them back words. I have been doing something like this:
int main()
{
string s="Hello there how are you?";
string temp="";
vector<string> tokens;
for(int i=0;i<s.size();++i)
{
if(s[i]!=' ')
temp+=s[i];
else
{
tokens.push_back(temp);
temp="";
}
}
for(int i=tokens.size()-1;i>=0;–i)
cout<<tokens[i]<<endl;
return 0;
}
Hand coding everything. But the problem is there is always one token missing. I don't get it why? And also please tell me if there is any convenient yet simple way to tokenize library in pure C++?
