Title: Programming in C for PCs and PICs
1Programming in C for PCs and PICs
- Contents Term 1
- Week 1 Introduction The C IDE
- Week 2 Basic C Code Data types and
expressions - Week 3 - Program Flow 1 Decisions (if)
- Week 4 - Program Flow 2 , Loops (while)
- Week 5 Arrays and structures
- Week 6 Methods
- Week 7 Debugging
- Week 8 File Input and Output
- Week 9 Test
2Programming in C for PCs and PICs
- Topics
- Errors
- Debug Window
- Debugger Options
- Breakpoints
- Stepping and running program
- Conditional Breakpoints
- Debug windows
3Programming in C for PCs and PICs
- Errors
- Your programs will have errors
- Compile time compiler traps
- Run-time
- Divide by zero, Number conversion, No file
- Logic Errors fault in brain
- Debugger provides tools to correct errors
4Programming in C for PCs and PICs
- Writing to the Debug Window
- Can write to window
- Use code
- System.Diagnostics.Debug.WriteLine(data)
- Appears in Debug Window
- Display with DebuggtWindowsgtOutput
5Programming in C for PCs and PICs
- 2. Debugger options
- Run the program to the cursor or breakpoint(s).
- To view, disable, enable and delete breakpoints.
- To set conditions on breakpoint operation.
- To pause the program.
- To restart in different ways after breakpoint or
pause. - To view, evaluate and modify variables.
6Programming in C for PCs and PICs
- 3. Setting breakpoints
- a) Run to cursor
- Right-click line choose run to cursor
- b) Click the line of code - Its highlighted.
7Programming in C for PCs and PICs
- 3. Setting breakpoints
- Run program
- Program stops, line highlighted in yellow
- Place cursor over variables to see them
8Programming in C for PCs and PICs
- 4. Continuing
- Inspect variables
- Run at full speed (F5)
- Step into code (F10) steps through methods
- Step over code (F11) runs methods at full speed
- Step out (ShiftF11)
- Debug toolbar
9Programming in C for PCs and PICs
- Conditional Breakpoints
- Full version only
- Break on a pass count and variable values
- Express edition?
- Add in your code, e.g
- if ((loopCounter 34) (variable 123))
-
- // set breakpoint here
10Programming in C for PCs and PICs
- Debug windows (not all in Express edition)
- 1. Local displays local variables
- 2. Watch displays specific variables
11Programming in C for PCs and PICs
- Debug windows - 2
- 3. Immediate Evaluate expressions
- 4. Call stack how did we get here?
12Programming in C for PCs and PICs
- Summary
- Errors
- Debug Window
- Debugger Options
- Breakpoints
- Stepping and running program
- Conditional Breakpoints
- Debug windows
13Programming in C for PCs and PICs
- If you want to, try it now. Do
- Week 7 tasks at
- www.det.mmu.ac.uk/staff/allwork