Creating Console Application
Creating Console Application
This work is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
Introduction This document explains how to create solutions, projects and C++ files in Visual Studio 2005. Solutions encapsulate projects and handle how those enclosed projects are built and deployed. This allows related projects to be setup under one solution. For simplicity, you can create one solution for one project or one solution for all your projects. However, this document shows how to create one solution with one project, but multiple projects can be added to the solution. The use of solutions and projects will become more apparent as you get familiar with Visual Studio 2005. Getting Started To create a solution, start Visual Studio 2005. From the File menu, select File, New, and Project. A file dialog will be displayed.
From the New Project dialog, select Visual C++ on the left-hand side (Project types), then select Win32 Console Application in the Templates. Type the name of the Project, choose a location (in the CS lab you will want to select c:\cwork), type the name of your solution, and check the box labeled Create directory for solution.
Select Console application if it is not selected and check the Empty project checkbox. Then click the Finish button. Visual Studio will create the solution and the project which can be viewed from the Solution Explorer.
You will notice that the Solution CoolCPlusPlus was created in addition to the CoolCPlusPlus project. Projects and solutions may have different names. You will also notice that are folders for Header Files (.h files), resources, and source files (.cpp files). This is where your .h and .cpp files will be created.
To create a .cpp (c++ source code file), right click on the Source Files folder. A popup dialog will appear, select Add, New Item. A file dialog will appear.
From the Categories, select Code and from the Templates choose C++ File (.cpp). Next type the name of the new .cpp file, CoolCPlusPlus.cpp, and then click on the add button. This will add a new file to the Source Files folder in the Solution Explorer and open the blank source file in Visual Studios text editor.
Once the CoolCPlusPlus.cpp file appears in the text editor you may type your source.
Make sure that your code is formatted and follows the provided style guide for the course. Once you save the file you can compile the code and execute it if you have no compilation errors.