csci n305 c language programming

20
1 CSCI N305 C Language Programming Welcome to CSCI N305! Welcome to CSCI N305! Compiling Your First Compiling Your First Program Using Microsoft Program Using Microsoft Visual Studio 2008 Visual Studio 2008

Upload: enya

Post on 14-Jan-2016

69 views

Category:

Documents


0 download

DESCRIPTION

CSCI N305 C Language Programming. Welcome to CSCI N305! Compiling Your First Program Using Microsoft Visual Studio 2008. Objectives for the Lab. Learn the difference between client-side and server-side programming Learn how to open an empty solution and project under Visual Studio .Net - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CSCI N305 C Language Programming

11

CSCI N305C Language Programming

CSCI N305C Language Programming

Welcome to CSCI N305!Welcome to CSCI N305!

Compiling Your First Program Using Compiling Your First Program Using Microsoft Visual Studio 2008Microsoft Visual Studio 2008

Page 2: CSCI N305 C Language Programming

22

Objectives for the LabObjectives for the Lab

Learn the difference between client-side Learn the difference between client-side and server-side programmingand server-side programming

Learn how to open an empty solution and Learn how to open an empty solution and project under Visual Studio .Netproject under Visual Studio .Net

Compile and run a simple programCompile and run a simple program

Page 3: CSCI N305 C Language Programming

33

Client-side vs Server-side compilingClient-side vs Server-side compiling

Environment setupEnvironment setup Install MS VS .Net 2008 from iuware.iu.eduInstall MS VS .Net 2008 from iuware.iu.edu

Client-side compiling runs locally on your computerClient-side compiling runs locally on your computer Requires installation of a compiler on your systemRequires installation of a compiler on your system Consumes local CPU and hard disk spaceConsumes local CPU and hard disk space No network (internet) connectivity requiredNo network (internet) connectivity required

Service-side compiling runs remotely on a serverService-side compiling runs remotely on a server Requires remote access software such as SSH available from iuware.iu.eduRequires remote access software such as SSH available from iuware.iu.edu Server is typically more powerful CPU and has more storage. Server is typically more powerful CPU and has more storage. Typically used for larger projectsTypically used for larger projects Easier to implement team development environmentEasier to implement team development environment Normally uses a command line interface rather than graphicalNormally uses a command line interface rather than graphical Network (internet) connectivity requiredNetwork (internet) connectivity required Used for business applications that require production infrastructure Used for business applications that require production infrastructure

(production monitoring, nightly backups, etc.)(production monitoring, nightly backups, etc.)

Page 4: CSCI N305 C Language Programming

44

Start Microsoft Visual Studio 2008Start Microsoft Visual Studio 2008

Start → All Programs → Microsoft Visual Start → All Programs → Microsoft Visual Studio 2008 → Microsoft Visual Studio Studio 2008 → Microsoft Visual Studio 20082008

Page 5: CSCI N305 C Language Programming

55

Starting for the first timeStarting for the first time

The first time you run The first time you run MSVS, you might get a MSVS, you might get a window like this.window like this.

Set Visual C++ Set Visual C++ Development Setting as Development Setting as your default your default environmental settings.environmental settings.

Use General Use General Development Settings if Development Settings if you have no preference.you have no preference.

Page 6: CSCI N305 C Language Programming

66

Initial MSVS WindowInitial MSVS Window

Here is an image of the initial window.

Page 7: CSCI N305 C Language Programming

77

Opening a New ProjectOpening a New Project

Open a project using File → New Project → Visual C++ → Open a project using File → New Project → Visual C++ → Win32 → Win32 Console Application → enter your project Win32 → Win32 Console Application → enter your project name and browse to select a location (where your project name and browse to select a location (where your project will be saved) → OK.will be saved) → OK.

Page 8: CSCI N305 C Language Programming

Project SettingsProject Settings

Choose Next > at this dialog.Choose Next > at this dialog.

Page 9: CSCI N305 C Language Programming

99

Project Settings (continued)Project Settings (continued)

Be sure to check Empty project and Finish.Be sure to check Empty project and Finish.

Page 10: CSCI N305 C Language Programming

1010

Add a New ItemAdd a New Item

Right-click Right-click on Source on Source Files and Files and Add a New Add a New Item.Item.

Page 11: CSCI N305 C Language Programming

1111

Create a .c FileCreate a .c File

Choose Visual C++ Code, C++ File, enter a file name with Choose Visual C++ Code, C++ File, enter a file name with .c as the file extension..c as the file extension.

Page 12: CSCI N305 C Language Programming

1212

Enter Code into Your FileEnter Code into Your File

Enter a standard C program into the .c file.

Page 13: CSCI N305 C Language Programming

1313

Save and Compile Your ProgramSave and Compile Your Program

Save → Build → Build SolutionSave → Build → Build Solution

Page 14: CSCI N305 C Language Programming

1414

Save and Compile Your ProgramSave and Compile Your Program

A successful build:A successful build:

Page 15: CSCI N305 C Language Programming

1515

Save and Compile Your ProgramSave and Compile Your Program

An unsuccessful build, read the error message and An unsuccessful build, read the error message and correct the errors and build again:correct the errors and build again:

Page 16: CSCI N305 C Language Programming

1616

Run the ProgramRun the Program

After a successful build, Debug →Start Without Debugging After a successful build, Debug →Start Without Debugging to run the program:to run the program:

Page 17: CSCI N305 C Language Programming

1717

Run the ProgramRun the Program

Examine the output:Examine the output:

Page 18: CSCI N305 C Language Programming

1818

Congratulations!Congratulations!

You created a new Microsoft Visual Studio 2008 You created a new Microsoft Visual Studio 2008 Project.Project.

Selected Visual C++ Win32 Console Application.Selected Visual C++ Win32 Console Application. Created your own .c file, entering code just like in Created your own .c file, entering code just like in

class.class. Ran your program to produce output.Ran your program to produce output. You did all of this using an easy editor without You did all of this using an easy editor without

logging onto the internet.logging onto the internet.

Page 19: CSCI N305 C Language Programming

1919

Open an Existing ProgramOpen an Existing Program

If your project is named projectOne:If your project is named projectOne: Find the projectOne folder at the location where Find the projectOne folder at the location where

you saved your project. you saved your project. In the projectOne folder, double click on the file In the projectOne folder, double click on the file

projectOne.vcproj, or projectOne.sln. projectOne.vcproj, or projectOne.sln. Double click on the .c file (e.g. main.c) will only Double click on the .c file (e.g. main.c) will only

open up the code file. It will not let you compile open up the code file. It will not let you compile or run the program using Visual Studio 2008. or run the program using Visual Studio 2008.

Page 20: CSCI N305 C Language Programming

2020

Submit a ProgramSubmit a Program

You only need to submit the .c file. You only need to submit the .c file.