C Tutorial Lab Worksheet 1

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 7

C TUTORIAL LAB WORKSHEET 1: Building and Running an Empty Win32 Console Application Project

In this tutorial, we will be getting familiar with compiler. How to Build and Run Your First An Empty Win32 Console Application Project The OS used is Windows XP Pro with Service Pack 2 and compiler is Visual C++ 2010 Express. Now we are going to create, build and run a very simple C program. During the process we will explore some of the common Visual C++ 2010 functionalities. You should be familiar with the steps in this module because the same steps will be used for all the lab practice.

1. First of all launch your MSVC ++ 2010 . Click the File New Project menu. Or
the shortcut key Ctrl+Shift+N.

2. The New Project form will be launched. On the left window we have CLR, Win32
and General project types. On the right we have templates for those project types respectively.

3. Select the Win32 project type and Win32 Console Application template as shown
below. Put the project name in the Name: field. Change the project (and all it files) Location: as needed. The solution default name is similar to the project name, change it if required and then click the OK button.

4. Win32 Application Wizard form will be launched. In this form we will further refine
our Win32 console application settings. The Overview page gives a summary about our project.

5. Select the Application Settings on the left. Select Console Application under
Application Types and Empty Project under Additional Options. Then click the Finish button.

6. Our project should be launched in VC++ 2010 EE. Now we only have an empty
Win32 console application project. We need to add file to the project. Lets add a C source file to the project. Select Project Add New Item menu. Or shortcut Ctrl+Shift+A

7. The Add New Item form will be displayed as shown below. We have several
categories of project items and their respective templates as well. For this exercise select Code under Categories and C++ File (.cpp) under templates. Put the source file name in the Name: field. The Location: should be default to our project. Then click the Add button.

8. Next, just type the following loose C sample code in the editor (right window).
#include <stdio.h> void main(void) { // statement 1; // statement 2; // more statements // as needed... }

9. Next select Project your_project_name Properties menu. Or shortcut Alt+F7

a. All the project settings can be changed/enabled/disabled here. Expand the


Configuration Properties folder and then expand the C/C++ subfolder. Click the Advanced link. Click the Compile As (default). From the list select Compile as C Code (/TC).

b. Click the Apply button and then select OK.

10. We are now ready to build our empty Win32 Application. Select Build Build
<Project name>.

a. You can view your results at the output window.

b. You can also run your program by selecting Debug Start Without
Debugging. Or shortcut Ctrl+F5.

c. Your result should look like this for an empty Win32 Application.

You might also like