W * cos(t) * (fabs (pow (cos (t), (2/n)-1)))

and not

W * cos(t) * (fabs (cos (pow t, (2/n)-1)))

Mark points out that a negative number raised to a fractional exponent will not yield a real number, so the equation really should be:

W * cos(t) * (pow (fabs(cos (t)), (2/n)-1))

Jackson pointed out that the exponent should be (2/n) - 1 for this to reduce properly to the ellipse, but something's still screwy here, as this only works for the range n = (0,2].

If your myKeyboardFunc doesn't get called, make sure you're registering it in main.

Aaron sent mail explaining how to write an animation that can be terminated mid-stream by a key click (or whatever) using the "idle" callback function glutIdleFunc. For example, you can register your display function as the idle function (i.e., glutIdleFunc(display)), ensuring that it is called repeatedly until there is some device input to break the loop (i.e. keyboard input).