If your project is set to use precompiled headers, the precompiled header must be THE VERY FIRST THING in the file. Only comments can be before it, nothing else.
1) don't use precompiled headers
2) #include your precompiled header first
In VS, unless you specifically state you want an empty project, it will often default to using precompiled headers, so you need to #include "stdafx.h" first.
this is Win32 main function so why would that open CMD?
are you shore you've selected console application?