I moved my code to use std::vector instead of char *mem = malloc(...) but now I am facing a problem that I can only access the vector d
std::vector
char *mem = malloc(...)
Of course. The vector was designed for this purpose:
char * p = &(myVector[0]) ;
And now, p points to the first item in the vector, and you can access each item by playing with the pointer, as you would in C.