You tell the compiler to dereference ptr, but since ptr is void* it has no idea what the memory at ptr is meant to look like. Should it read the data as an integer? A floating point value? Some arbitrary structure? It won't choose, and thus the error.