Home > Articles > Programming > C/C++

  • Print
  • + Share This
This chapter is from the book

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.

  1. 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.
  2. From the File menu (the first menu on the menu bar), choose the New Project command. The New Project window then appears.

    01fig02.jpg

    Click to view larger image

    Used with permission from Microsoft.

  3. In the left pane, select Visual C++.
  4. In the central windowpane, select Win32 Console Application.
  5. 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.
  6. 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.

01fig03.jpg

Click to view larger image

Used with permission from Microsoft

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;
}
  • + Share This
  • 🔖 Save To Your Account