GLUT JOYSTICK doesn't work- from superbible

I have a small code example called “Terrain1.c” taken from OpenGL Superbible book. In this example the author shows how to code joystick by using GLUT. All seems to be easy basically just few lines of code but I have a big problem with getting this thing to work.
I have the example on CD precompiled with exe file, so if I double click on the exe (without compiling the project) file then the program obviously works and the joystick works too. but whenever I recompile (VC6++) the original project created by the author then the joystick doesnt work. I dont get any errors. it compiles but joystick doesnt work. I have all the latest glut files. Its weird! why??
If there is someone who has tried this and got it working then please let me know!!
I am stuck with it already for a few days!