Code:
#include <stdio.h>

int main(void)
{
    double x = 100.1, y;
    int *p;

    /* The next statement causes p (which is an
    integer pointer) to point to a double. */
    p = (int *)&x;

    /* The next statement does not operate as
    expected. */
    y = *p;

    printf("%f", y); /* won't output 100.1 */
    return 0;
}
p is a pointer to an integer.

On line 10, why is p cast as a pointer to an integer?
Is this an error in the sample code?

Shouldn't it be cast as:
Code:
p = (double *)&x;