'void*' is not a pointer-to-object type

Please look at the situation where I'm wishing view data using pointer to void, and it displays following error ['void*' is not a pointer-to-object type].

#include<iostream.h>
#include<conio.h>
main()
{
int i=50;
void *ptr;
ptr=&i;
cout<<*ptr; //Error Message: 'void*' is not a pointer-to-object type
getch();
}

Please help, why this error occuring?
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.
Topic archived. No new replies allowed.