1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to...

12
Getting Started The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0 As shown in Figure 1, to start Visual C++ 6.0 click on Start in the bottom left hand corner and then use the mouse to move down the following chain: Programs | Microsoft Visual Studio 6.0 | Microsoft Visual C++ 6.0 Figure 1 Starting Visual C++ 6.0. This will bring up the following screen:

Transcript of 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to...

Page 1: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Getting Started The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0.

1.1 Starting Visual C++ 6.0 As shown in Figure 1, to start Visual C++ 6.0 click on Start in the bottom left hand corner and then use the mouse to move down the following chain:

Programs | Microsoft Visual Studio 6.0 | Microsoft Visual C++ 6.0

Figure 1 Starting Visual C++ 6.0.

This will bring up the following screen:

Page 2: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 2 Visual C++ 6.0 Opening Screen.

We have a typical windows application layout with menus and toolbars and three blank sub-windows.

1.2 Simple Program Development We will now look at using Visual C++ 6.0 to compile, link and run a simple program. Here is the program we will be using: #include <stdio.h>

main(void){

printf("Welcome to Introduction to C Programming.\n");return 0;

}

Step 1 – Create a Project Click on the File menu and select New. This will bring up the following screen:

Page 3: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 3 Starting a new project.

Four tabs are provided and if the Projects tab has not come up by default then click on it. We are interested in a project of type – Win32 Console application. Then we use the dialog boxes on the top right to choose both a project name and location. It is suggested that you choose a location first from which to base all projects. As you fill in the project name box the name will be added as a sub-directory of the location entry.

Step 2 – Choose Project type Click OK and the following window appears:

Page 4: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 4 Selecting a project type.

If “An empty project” button is not selected then choose it and click on Finish at the bottom.

Step 3 – New Project information Click Finish and you should see the figure as shown in Figure 7. The key features of this project are:

• Win32 Console Application. • Empty console application. • No files will be created or added to the project. • Project directory.

Page 5: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 5 New project information.

Step 4 – Create your source file Click OK and you get the project called “First” shown in the top left sub-window. Next, we will create our source file. Click New Text File button on the left of the toolbar as shown below.

Page 6: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 6 New text file.

This will bring up an editor window called Text1, and type in the program on it.

Figure 7 Type in program.

Page 7: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

After finishing typing in the program, we need to save the file as shown below.

Figure 8 Save the source file.

Step 5 – Add file into project We need to add the source into the created project in order to compile and execute the program. Click Project menu | Add To Project and select Files.

Page 8: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 9: Add file into project

Then choose the source file to add to the project as below.

Figure 10 Choose file and add to project.

Page 9: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Step 7 – Compile the program Click Build menu and Compile First.c as shown below. Press Ctrl+F7 also can do the same compilation process.

Figure 11 Compile the program.

The compilation result of the program will be shown in the bottom sub window as below.

Page 10: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 12 After compilation of the program.

Step 8 – Build the application This step builds the executable file. Click Build menu and select Build First.exe. Press F7 also can do the same building process.

Page 11: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Figure 13 Build executable file.

The building process result will be shown in the bottom sub window as well.

Figure 14 Result of building the executable file.

Page 12: 1.1 Starting Visual C++ 6 - Nanyang Technological University · The aims of the chapter are to provide a quick introduction to the use of Visual C++ 6.0. 1.1 Starting Visual C++ 6.0

Step 9 – Execute the application Click Build menu and select Execute First.exe, you will see the popped up DOS window showing the program output.

Figure 15 Program running.

The text message “Press any key to continue” enables you to see the output from the program. A stand alone executable file will also have been created in the corresponding project directory.

1.3 Summary There are a lot to assimilate. It is recommended that you try creating several simple programs within Developer Studio to get some practices on the following points:

• The menu options. • The toolbars • The Developer Studio visual environment. • Projects. • Building your application. • The locations of the directories and sub-directories where Developer Studio

organizes your work files.