70 likes | 105 Views
Learn how to debug effectively with four strategies: avoid reinventing the wheel, test code incrementally, code defensively, and include debugging code. Understand and identify program bugs, syntactic and semantic errors, and how to debug using tools like breakpoints and debug windows. Master debugging steps and techniques to enhance programming skills.
E N D
Chapter 11 Debugging Techniques Date: 2008/05/08
Four strategies • Don’t re-invent the wheel. • Develop and test your code incrementally. • Code defensively. • Include debugging code.
Program bugs • Syntactic errors • ex. cout << “hello”; count << “hello”; error • Semantic errors • ex. char array[5]; array=“school”; error • Sometimes the program terminates abnormally.
Debug(1/2) • Starting Debug F5 • Step over F10 • Step In F11 • Debug toolbar • Tools customize
Debug(2/2) • Debug windows can help us debug. • Debug windows (while Debugging) • Autos • Output • Callstack • Watch • Error Lists • Breakpoints ……
Breakpoints • A breakpoint is a point in your program where the debugger automatically suspends execution. • Set condition
Adding Debug code • Solution Configuration • Debug • Release • #ifdef _DEBUG //Debug code #endif