You need to convert v to an appropriate (non-void) pointer type, otherwise v[i] is invalid (there is no such thing in C++ as an array of voids).

All the compiler knows about v in your last loop...