I am trying to overwrite an element (of unknown size) “copyHere” with newElement, but I am having problems. I set copyHere to the chunk of the elementArr of which I want to overwrite:
void *copyHere = ((char *)elementArray + (i * elementSize));
copyHere = memcpy(copyHere, *newElement, elementSize);
I am getting an error, “invalid use of void expression”. How am I misusing the void * or memcpy? From my understanding, I feed in memcpy a destination block of memory and a source block of memory and the size of the source that I want to copy. I have done this. And for void *copyHere, I have traversed through the elementArray (of unknown type, but known size elementSize) to find the block of memory I want to overwrite. Any clues?
Remove the
*beforenewElement. You cannot (and do not need to) dereference avoidpointer to pass it tomemcpy.