memcpy to copy the contents of one pointer to another pointer assigned to new memory. Later in the program I get runtime errors as if I were attempting to operate on a pointer pointing to nothing. While debugging, I saw that the original and the the copied pointer had different addresses but they acted as if they were one, for example If I set a property of the copied pointer to 'a' the original would also get set to 'a'. In this case I delete the copied pointer and the original gets deleted too as if they pointed to the same memory.
I dont use
memcpy often, as far I understand it copies memory of one object to another basically creating a clone
This is how i used it:
T* toreturn = new T; memcpy(toreturn, pr, sizeof(*pr));