How does one edit void pointers? Obviously, this is possible in C, because there are many standard library functions that do this.
I thought I'd implement a function swapping two array elements (I know there is a standard function for it, it's just an exercise), so ideally I'd want to do this:
void swap(void *arr, int a, int b, int elSize) {
void arrEl = arr[a];
arr[a] = arr[b];
arr[b] = arrEl;
}
Of course, I can't dereference a void pointer, nor can I have a variable of type void, so I have to work around that somehow, but I discovered I don't know how to edit a void type array.
So how should I implement above pseudo-C?
I saw this thread, but I am not sure how to apply that and think seeing the correct version of above pseudo-C will make it a bit more clear.
arrElasvoid?arris ofvoid *type.