BIM111 Introduction to Computer Engineering - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

BIM111 Introduction to Computer Engineering

Description:

Select 'C File(.cpp)' Type the name of the file. ... cpp-tutorial/a4-debugging-your-program-stepping-and-breakpoints/ http://www.learncpp.com/cpp-tutorial ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 35
Provided by: Sev73
Category:

less

Transcript and Presenter's Notes

Title: BIM111 Introduction to Computer Engineering


1
BIM111 Introduction to Computer Engineering
  • Visual Studio 2008

2
Visual Studio 2008
3
(No Transcript)
4
Creating a New Project
  • To create a new project,
  • File gtgt New gtgt Project (ShortcutCtrlShiftN)
  • Visual C gtgt General gtgt Empty Project
  • Type name of the project and select the location
    of the project files then click OK.

5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
Adding Source Files
  • To add a source file to your project,
  • Project gtgt Add New Item (CtrlShiftA) or
  • Right click on Source Files of project in
    solution explorer. Then, click Add New Item.
  • Add New Item form will be appeared.
  • Select C File(.cpp)
  • Type the name of the file. Do not forget .c (e.g.
    HelloWord.c or Project1.c) extension.

9
(No Transcript)
10
(No Transcript)
11
Do not forget .c extension !
If you write the name of file without .c
extension, it creates a C source file not C
source file
12
(No Transcript)
13
(No Transcript)
14
Running the Project
  • Firstly, you must build the project
  • Build gtgt Build Solution (F6)
  • To run your project,
  • Debug gtgt Start Without Debugging (Ctrl F5)

15
(No Transcript)
16
(No Transcript)
17
(No Transcript)
18
Running Executable Project File
  • Open the folder where you save the project.
  • Double click on Debug folder.
  • Double click on the executable file (.exe)
  • Alternatively, you can run your execulable file
    using command promt. Find the directory where the
    executable file exists then type Project1.exe

19
Executable Project File
20
(No Transcript)
21
Opening an Existing Project
  • To open a project
  • File gtgt Open gtgt Project/Solution
    (CtrlShiftO)
  • Select the solution file (Project.sln) then
    click OK.
  • You can also open an existing project by double
    clicking on solution file (Project.sln)

22
(No Transcript)
23
Solution file Project2.sln
24
Debugging
  • Programming is difficult, and there are a lot of
    ways to make mistakes.
  • A syntax error occurs when you write a statement
    that is not valid according to the grammar of the
    C language.
  • The compiler will generally catch syntax errors
    and generate warnings or errors so you know what
    the problem is.

25
Debugging
  • A semantic error occurs when a statement is
    syntactically valid, but does not do what the
    programmer intended.
  • Unfortunately, the compiler will not be able to
    catch these types of problems.
  • A debugger is a computer program that allows the
    programmer to control how a program executes and
    watch what happens as it runs.

26
Debugging
  • The programmer can use a debugger to execute a
    program line by line, examining the value of
    variables along the way.
  • By comparing the actual value of variables to
    what is expected, or watching the path of
    execution through the code, the debugger can help
    immensely in tracking down semantic errors.
  • To debug your program, you must select Debug gtgt
    Start Debugging (F5)

27
Stepping
  • Stepping is a debugger feature that lets you
    execute (step through) your code line by line.
  • Step into (F11) The step into command executes
    the next line of code. If this line is a function
    call, step into enters the function and returns
    control at the top of the function.

28
Stepping
  • Step over (F10) This command executes the next
    line of code. If this line is a function call,
    step over silently executes the function and
    returns control after the function has been
    executed.
  • Step over provides a convenient way to skip
    functions when you are sure they already work or
    do not need to be debugged.

29
Stepping
  • Step out (Shift F11) Step out does not execute
    the next line of code.
  • Instead, it executes the rest of the function you
    are currently in, and returns control to you when
    the function has finished executing.

30
Break Points
  • In a large program, it can take a long time to
    step through your code just to get to the point
    where you want to examine in more detail.
  • A breakpoint is a special marker that tells the
    debugger to stop execution of the program at the
    breakpoint when running in debug mode.
  • Continue (F5) This command executes the program
    like normal until it gets to the line of code
    selected by breakpoint. You can debug starting at
    that point.

31
(No Transcript)
32
Watching Variables
  • The debugger also lets you examine the value of
    variables as you step through your code.
  • Watching a variable is the process of inspecting
    the value of a variable while the program is
    executing in debug mode.

33
(No Transcript)
34
References about Debugging
  • Look at following references for details about
    debugging
  • http//www.learncpp.com/cpp-tutorial/a4-debugging-
    your-program-stepping-and-breakpoints/
  • http//www.learncpp.com/cpp-tutorial/a5-debugging-
    your-program-watching-variables-and-the-call-stack
    /
Write a Comment
User Comments (0)
About PowerShow.com