It really depends, what error/mistake are you talking about?
1. If you're going to point to a double, use a pointer to a double (double* myDoublePtr).
2. If you're going to screw it up anyway, I think you can get that code to work like this:
Code:
double x = 100.1; double y; int *p;
p = (int *)&x;
y = *((double*)p);
However, I haven't tested that code, I just believe that rational thinking makes it right. Any pointer is just a pointer, so it occupies the same amount of memory, it has the size to hold a memory address. When you make an int pointer point to a double, you're making it point at the memory location where that double is, so in reality, it's the same as having any other pointer pointing to that area.
The "real" problem begins when you assign the value that resides at the memory address pointed to by your pointer. Since you are treating the contents of that memory address as the contents of an int, the compiler will copy the value of the integer and assign it to the double. But that's not an integer! So whatever bits are there, they DO NOT represent an integer, so you'll be assigning an integer to a double that isn't even an integer. By assigning I mean:
Code:
int a = 50;
double b = a;
The above code implicitly assigns the integer a to b, which is what you do when you dereference your p pointer. (remember, the type of *p is int!). Hence, if you cast the pointer to double* (pointer to double), the compiler will interpret the data at that memory address as a double and, instead of assigning the integer that lives there, it assigns the double. Someone correct me if I threw a lot of BS in here.
So, anyway, you shouldn't be using "int*" when you're going to point to a double. Use "double*"