For a list of reasons that I do not control, I need to create an array of strings that needs to be referenced from a void* pointer. The idea is to follow the following pattern in C++:
void* TP = malloc(sizeof (double) * SS);
for (int i = 0; i < SS; i++) {
((double*) TP)[i] = IStringToDouble(Token[i]);
}
Where Token is a vector and SS an int. Now, using that template, I though starting with something like:
void* TP = malloc(sizeof (string) * SS);
for (int i = 0; i < SS; i++) {
((string*) TP)[i] = Token[i];
}
I know that this is horribly wrong, but all the modifications I have tried starting from it don't work.
Any suggestion about how to achieve this? Is it possible?
I have gone through all the documentation about string arrays on C++ that I have found from Google or StackOverflow, but none of them covers the issue about referencing the array from a void*.
Token[i], and how will the strings be accessed?TP's pointers just point into that vector then? Instead of trying to allocate new strings?