Use memcpy()
.
void set_value(void * data, void * value, size_t size, int index){
void * position = (char*)data + index*size;
memcpy(position, value, size);
}
Note also that arithmetic on void pointers is not valid C, although it may be allowed as a compiler extension. You should cast to char*
first.