/* * This code, with deliberate array errors, could do almost anything * when it prints x and z and will probably then segfault. */ #include #include int main() { double x = 0, y[2], z = 0; int i; printf("x is at %p y at %p z at %p\n", &x, y, &z); for (i = 0; i <= 2; ++i ) /* !! */ y[i] = sqrt(2.0); printf("X is %f z is %f\n", x, z); /* If you thought the previous loop was bad ... */ while ( 1 ) { i *= 12345; printf("i is %d\n", i); y[i] = y[-i] = sqrt(3.0); } return 0; }