int main() { string str; cin >> str; //獲取輸入 vector<string> svec(str.length()); for (unsigned int i = 0; i < str.length(); i++) //保存在vector中 { svec[i] = str[i]; } string *pstr = new string[str.length()]; //動態創建數組 for (unsigned int i = 0; i < str.length(); i++) //復制給新數組 { *(pstr+i) = svec[i]; cout << *(pstr+i); } delete []pstr; //釋放內存 return 0; }