int ReqSubMarketData(std::vector<std::string>& vecInstrucment)
{
char** destination = new char*[vecInstrucment.size() + 1];
MakeCString(vecInstrucment, destination);
// param char* ppD[], int nSize
SubscribeMarketData(destination, static_cast<int>(vecInstrucment.size()));
// 释放资源
for (int n = 0; n < static_cast<int>(vecInstrucment.size()); n++)
{
delete[] (destination[n]);
}
delete[] destination;
destination = NULL;
return ERR_OK;
}
void MakeCString(const std::vector<std::string>& source, char** destination)
{
// 注意释放内存
for (int n = 0; n < static_cast<int>(source.size()); ++n)
{
destination[n] = new char[32];
destination[n][31] = '\0';
strncpy(destination[n], source[n].c_str(), 31);
}
//destination[source.size()] = NULL;
}
vector<string>转换为char*[]
最新推荐文章于 2023-01-17 12:49:13 发布