CPS120: Introduction to Computer Science - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

CPS120: Introduction to Computer Science

Description:

CPS120: Introduction to Computer Science Compiling Your Programs Using Visual C++ – PowerPoint PPT presentation

Number of Views:91
Avg rating:3.0/5.0
Slides: 16
Provided by: wcc87
Learn more at: http://space.wccnet.edu
Category:

less

Transcript and Presenter's Notes

Title: CPS120: Introduction to Computer Science


1
CPS120 Introduction to Computer Science
  • Compiling Your Programs Using
  • Visual C

2
Compiler Files
  • Source code (.cpp)
  • Linked/Library file
  • Object file (.obj)
  • Executable file (.exe)

3
Executable Files
  • A machine-language executable file created when
    the compilation process is complete
  • All that is needed to run the program
  • Not human-readable
  • Has the extension .EXE
  • Stored in binary form
  • Copies may be distributed (portable)
  • Known as an application

4
Compiling and Debugging
  • Executable code will not be created until you
    correct all of the syntax errors in your source
    code
  • Then the fun (with logic errors) begins

5
Creating Source Code Files
  • Actually Compiling a Program

6
Creating Source Code
  • Dont use a word processor
  • You can use WordPad or NotePad
  • An editor specifically designed for C is
    available in the Visual Studio IDE

7
Using the Editor
  • Save often because there is no autosave in Visual
    C
  • The editor will do matching of delimiters and
    intelligent indentation

8
Color Coding in Visual C Editor
  • Comments are green and are ignored by the
    compiler
  • All ANSI keywords are coded in blue
  • Other code is in plain black
  • Compiler keywords like cin and cout are also
    shown in black

9
Setting Up a Visual C Workspace
  • Left-click START
  • In the program section, select Visual Studio or
    Visual C (depending on what is installed)
  • Left click on the Visual C icon to load the
    environment
  • Create a new work area by choosing FILE/NEW
  • Choose FILES tab
  • Click on the C Source File to reach the editor
  • Add a filename and directory before continuing
  • e.g. c/cppFun/myFirstCpp

10
Setting Up a Visual C Workspace
  1. Create the directory with START / EXPLORE
  2. Double-click the drive letter
  3. Choose FILE, NEW FOLDER
  4. Left click on FOLDER
  5. Change new folder to cppFUN
  6. Close Explorer with the X
  7. Back in Visual C, type myFirstCpp in the file
    box
  8. Click OK and get back to the main edit screen

11
Setting Up a Visual C Workspace
  1. Enter the source code
  2. After entering the program, FILE then SAVE

12
Why Create New Subdirectories?
  • You should always use subdirectories to store
    your files. Visual C creates quire a few work
    files when it generates the executable file for
    you source code, and they will be easy to dispose
    of if you keep everything together in one
    convenient place.
  • Under no circumstances should you use the root
    (C\) directory except on a floppy disk (A\).

13
Running the Program
  1. Press the REBUILD ALL button. It has two arrows
    in a box
  2. Press the RUN button. It is a red exclamation
    point

14
Disk Space Issues
  • Text files are insignificant in terms of space
  • However, at least six other files are created
    every time something is compiled some get around
    95 full
  • Highlighting the disk in are 3 or 4 times larger
    than the source
  • You can delete anything but the file with the
    .cpp suffix everything else can be recreated

15
Recompiling
  • Open the file by going the file you stored it in
    and double clicking on it
  • Scan the source code for obvious errors before
    attempting to compile
  • Attempt to compile using the COMPILE button or
    choosing the first option on the BUILD menu
  • Answer Yes to use the default project workspace
  • The lower window will be active and the compile
    will occur
  • Note the number of errors and warnings
  • These need to be dealt with before executable
    code is created
Write a Comment
User Comments (0)
About PowerShow.com