#include <iostream> #include <vector> #include <string> using namespace std; int main() { vector<string*> spvec; string str; while(cin>>str) { string *sp = new string; *sp = str; spvec.push_back(sp); } vector<string*>::iterator iter = spvec.begin(); while(iter!=spvec.end()) { cout << **iter << "\t" << (**iter).size() << endl; ++iter; } iter = spvec.begin(); while(iter!=spvec.end()) { delete *iter; ++iter; } return 0; }
原文地址:http://blog.csdn.net/xumesang/article/details/45565325