Session-4 CSIT 121 Spring 2006 - PowerPoint PPT Presentation

About This Presentation
Title:

Session-4 CSIT 121 Spring 2006

Description:

Debugging Tips. Let us try a few simple steps ... cout 'How many miles does your car cover in one gallon (MPG rating from the sticker) ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 9
Provided by: sunyfr
Category:
Tags: csit | session | spring

less

Transcript and Presenter's Notes

Title: Session-4 CSIT 121 Spring 2006


1
Session-4 CSIT 121 Spring 2006
  • Debugging Tips
  • Lab Work

2
Some Aspects of Visual Studio
  • Your project can be set in Debug or Release
    configuration (Build-gtConfiguration Manager)
  • In Debug state, you can apply several debugging
    options.
  • Debug is set by default
  • You can start debugging by invoking the debugger

3
Debugging Tips
  • Let us try a few simple steps
  • Open a new Win32 console project and copy and
    paste the following program into the editor
    window
  • The compiler gives an error message
  • Click on the error message
  • The system moves the pointer to the line where
    the error is, press F1 to learn more

4
Program With an Error
  • include ltiostreamgt
  • using namespace std
  • void main()
  • double kpl,mpg, kpg
  • const double CF1.6
  • coutltlt"How many miles does your car cover in one
    gallon (MPG rating from the sticker)?"
  • cingtgtmpg
  • kpg mpgCF
  • coutltlt"Your KPG rating is "ltltkpgltltendl
  • kpl kpg/3.78
  • coutltlt"Your KPL rating is "ltltkplltltendl

5
Starting the Debugger
  • Once you have compiled the project, you can start
    the debugger by first inserting breakpoints
  • A Breakpoint is where the program execution will
    halt
  • Thus you can see the values of variables at that
    point

6
Using the Debugger
  • Inserting breakpoints is a convenient way of
    stopping at a suspected problem location and
    examining the values of variables (Click the gray
    panel to the left of the program to insert a
    breakpoint)
  • Click on Debug? Start
  • Look at the bottom of the screen. You will find
    Autos on the left and call stack on the right
  • Autos represents the variables. Look at the
    values. Which one is not assigned a value yet?
  • Choose step over from the icons to avoid
    stepping into system functions

7
Directories
  • Choose Tools?Options?Environment and change the
    project directory
  • You can browse the Buildlog.htm file in the Debug
    folder to appreciate the automation of the linker

8
Lab Work (Part-D Due 2/2)
  • Part-A
  • Solve Prelab assignment on pages 31-32 of the lab
    course textbook. (Exercises 1,2,3,4,5)
  • Check the solution and make any corrections
  • The program source code is on the course website
    in the labs and lectures page
  • Part-B
  • Carry out all the four exercises in lesson 2-2 on
    page 34
  • Part-C
  • Do exercises 1,2,3 in Lesson 2-3 (page 35)
  • Part-D
  • Exercise 1 and 2 of Lesson 2-4 are due Thursday
    Feb 2
Write a Comment
User Comments (0)
About PowerShow.com