I know how to do pointer arithmetic using arrays, but how do I do pointer arithmetic without them?
For my current assignment I have a void pointer to a memory address. I have a size_t
which is storing a size in megabytes.
I am trying to add the half of the megabyte size to the pointer to find a memory address x/2
megabytes away from the pointer.
So
void *ptr = malloc(size_t x)
void *ptr2 = ptr+x/2;
but the compiler says these datatypes are incompatible. what is the right syntax to do this?