二种转换方式,一种是直接获得vector首地址的指针,别一种再copy一份
vector<char*> vecChar; char* p1 = "p12113"; vecChar.push_back(p1); char* p2 = "fdsafdsa"; vecChar.push_back(p2); char* p3 = "sasssssss"; vecChar.push_back(p3); char** a1 = &vecChar[0]; for (int z = 0; z < vecChar.size(); z++) { cout << "pointer: " << *(a1 + z) << " "<< z << " " << vecChar[z] << endl; } char* arr[vecChar.size()]; std::copy(vecChar.begin(), vecChar.end(), arr); for (int z = 0; z < vecChar.size(); z++) { cout << "copy: " << arr[z] << " "<< z << " " << vecChar[z] << endl; }