You set up your project to use precompiled headers which is what stdafx.h is for.

1. Create a new project.
2. In the first dialog box select console application.
3. In the next dialog box do not click Finish to accept the current settings. Instead click Next.
4. In the following dialog box deselect Precompiled header, then select Empty project. Make sure you deselect Precompiled header before selecting Empty project, otherwise Precompiled header will be still selected but dimmed out.
5. Now click Ok.
6. Add a new cpp file to your new project and copy and paste in your old code.
7. Remove the lines: