I'm trying to create a dynamic 2d std::string vector but having trouble adding the new rows:
std::vector<std::vector<std::string>> hops_vector;
int Hop = 0;
for (Hop = 0; Hop < RouteHops; Hop++)
{
char HopIPString[20];
HopIPString[0] = 0;
RouteTestGetHopTimedOut(TestHandle, Hop, &HopTimedOut);
std::string thehop = std::to_string(Hop + 1);
//If the hop hasn't been registered yet
if (hopsstring.find(thehop) == std::string::npos) {
vector<int> row; // Create an empty row
hopsstring += thehop+","; // Add hop number to hop string
//Add columns for pings per hop + IP and Loss/No Loss
for (int j = 0; j < PingsPerHop+2; j++) {
row.push_back(j); // Add an element (column) to the row
}
hops_vector.push_back(row); // Add the row to the main vector
hops_vector[Hop][0] = thehop;
}
}
The line hops_vector.push_back(row);
gives me a no instance of overload error. I assume because hops_vector is an std::string vector. Changing it to an int solves that issue but then I can't add string to the vector!