- Install Microsoft Visual Studio
- Create a Project with Microsoft
- Writing a Program in Microsoft Visual Studio
- Running a Program in Visual Studio
- Compatibility Issue #1: stdafx.h
- Compatibility Issue #2: Pausing the Screen
- If You're Not Using Microsoft
- Advancing to the Next Print Line
- Storing Data: C++ Variables
- Introduction to Data Types
- A Word about Variable Names and Keywords
- Chapter 1 Summary
Create a Project with Microsoft
There are some files and settings you need for even the simplest program, but Visual Studio puts all the items you need into something called a project.
With Visual Studio, Microsoft makes things easy by providing everything you need when you create a project. Note that you will need to create a new project for each program you work on.
So let’s create a project.
- Launch Visual Studio. After you’ve installed it, you should find that Visual Studio is available on the Start menu (assuming you’re running Windows). Visual Studio should then appear onscreen.
From the File menu (the first menu on the menu bar), choose the New Project command. The New Project window then appears.
- In the left pane, select Visual C++.
- In the central windowpane, select Win32 Console Application.
- There are four text boxes at the bottom of the window. You need only fill out one. In the Name box, type the name of the program: in this case, “print1.” The Solution name box will automatically display the same text.
- Click OK in the bottom right corner or just press ENTER.
The Application Wizard appears, asking if you’re ready to go ahead. (Of course you are.) Click the Finish button at the bottom of the window.
After you complete these steps, a new project is opened for you. The major area on the screen is a text window into which you can enter a program. Visual Studio provides a skeleton (or boilerplate) for a new program containing the following:
// print1.cpp: Defines the entry point... // #include "stdafx.h" int _tmain(int arg, _TCHAR* argv[]) { return 0; }
You’re probably asking, what is all this stuff? The first thing to be aware of is that any line that begins with double slashes (//) is a comment and is ignored by the compiler.
Comments exist for the benefit of the programmer, presumably to help a human read and understand the program better, but the C++ compiler completely ignores comments. For now, we’re going to ignore them as well.
So the part you care about is just:
#include "stdafx.h" int _tmain(int arg, _TCHAR* argv[]) { return 0; }