Hi
I have encountered a problem using vectors. I have a vector<char*> in a for loop, adding a char* to it after each iteration, but when I exit the loop and run through the contents of the vector, it has 4 copies of the final char* added.
Here is the code:
std::vector<char*> tempC;
char *c = new char[107];
c[106] = '\0';
tempC.clear();
for (int i = 0; i < 4; i++)
{
s = randomString(14) + ha + randomString(11);
stringToMpuint(s, xm);
EncryptDecrypt(ym, xm, d, n);
mpuintToChar(c, ym);
tempC.push_back(c);
}
I have checked the value of c before adding it to the vector and it is correct.
Does anyone know why this is happening?