I am working with a C project using visual studio. I tried to compile the following code:
void shuffle(void *arr, size_t n, size_t size)
{
....
memcpy(arr+(i*size), swp, size);
....
}
I get the following error with Visual studio Compiler:
error C2036: 'void *' : unknown size
The code compile well with GCC. How to solve this error?
void*pointer is, although there could be GCC extension that permits it. To do pointer arithmetic, you have to know the size of the data it points to. Note that adding1to a pointer to a 32-bitintwill add4to the pointer itself. Just like with array indexing, where you access the second element witharr[1]not witharr[4]. - Weather Vane