I have a string like "ABC DEF " with whitespace at the end. I would like to convert it into a vector of strings like {"ABC" "DEF"}, so I used a stringstream:
string s = "ABC DEF ";
stringstream ss(s);
string tmpstr;
vector<string> vpos;
while (ss.good())
{
    ss >> tmpstr;
    vpos.push_back(tmpstr);
}
However, the result vpos is {"ABC" "DEF" "DEF"}. Why the last word will be duplicated in the vector? And what is the correct code if using stringstream is required?
 
    