This pronlem usually turns up when you select Win32 Application which is a GUI application as the project type, and then write code for a Console Application (using int main () ).
Throw this project away, and start a new one, AND MAKE SURE that you select Win32 Console Application as the project type
and put the above code in the new project and see what happens.