SPECIAL OFFERS
Keep up with new releases and promotions. Sign up to hear from us.
Register your product to gain access to bonus material or receive a coupon.
Shows students how to fix these errors.
Teaches students how to trace the changes in variables and follow the execution of the program to locate errors that are not obvious.
Saves time for instructors who can ask students to show them a program trace when they come for help during office hours.
Teaches students how to use these popular debuggers, including stopping the program at any point and keeping track of all changes in variables.
Gives the students a one-page checklist of common bugs to reference when diagnosing and fixing errors.
Familiarizes students with a wide variety of programming errors and shows how to fix them either manually, with tracing, or when dealing with larger programs, with Microsoft Visual C++ and Metrowerks CodeWarrior.
Allows the more experienced student to quickly review their knowledge of debugging without having to wade through the fundamentals.
With this book, beginning programmers finally have a practical book on debugging techniques for C++. Practical Debugging in C++ serves as an important companion to any introductory textbook on C++ programming. Whether in the computer lab or at home, programmers should keep this book handy for quick reference when writing and debugging C++ programs.
The book includes chapters on:Beginning programmers will want to use this book because it is easy and fast to read with many simple examples. It will save many frustrating hours of debugging time when the tracing and system debugger techniques illustrated in the text and figures are applied.
For the intermediate programmer, particularly those with some experience in other languages, this guide provides a quick up-to-speed primer in C++ debugging with a series of examples of common syntax and semantic errors and how they can be detected and corrected.
Instructors in introductory programming classes will want to recommend this book to their students because it will enable them to become much more self-sufficient, greatly reducing the time students will need for individual consultation regarding their programs.
1. Introduction.
Chapter Objectives. Motivation for Debugging Skills. Approaches to Debugging.
Chapter Objectives. Syntax Errors. Syntax Warnings. Semantic Errors.
Chapter Objectives. Basic Tracing. Common Errors Detectable with Basic Tracing. Trace On and Off Flag. Tracing Using Function Calls. Tracing for Data in Arrays. Where to Insert the Traces and What Variables to Display. Using the Assert Macro.
Chapter Objectives. Strings. Pointers. Structs. Classes.
Chapter Objectives. Fundamentals. Debugging with Metrowerks CodeWarrior. Example: Debugging a Sample C++ Program Using Metrowerks CodeWarrior. Debugging with Microsoft® Visual C++™. Example: Debugging a Sample C++ Program Using Microsoft® Visual C++™.
This book is a tutorial on debugging techniques for both the beginning and intermediate programmer. For the beginning programmer it is meant to be a companion book to any introduction to programming in C++. Ideally this book is for students to take to their computer labs with them for quick reference when writing and debugging C++ programs. For the intermediate programmer, particularly those with some experience in other languages, this guide provides a quick up-to-speed primer in C++ debugging with a series of examples of common syntax and semantic errors and how they can be detected and corrected.
The motivation for this book came as a result of innumerable sessions in the computer lab with introductory programming classes at the University of Michigan. Unfortunately, many beginning programmers subscribe to the "programming by blind faith" method, writing the complete program, then hoping it will run correctly the first time without doing any intermediate testing, and then panicking when it crashes or generates bad data that cannot be explained. Each time they come to us with "What do I do now?" we go back to the program together to look over the basic logic, and then start inserting traces to check the intermediate results and localize the sources of error. We have come to the conclusion that students need a short, clear debugging guide as a valuable addition to their other programming tools, something they can easily carry with them and with which they can supplement their introductory programming textbooks.
Chapter 1 is a short motivational chapter that summarizes the common sources of errors in computer programs.
Chapter 2 describes the most common syntactic and semantic programming errors (with illustrative examples) and explains how to correct them.
Chapter 3 shows the student how to use output statements (cout) to trace variables in C++ programs, and how tracing can be easily inserted into his or her own programs. Several examples are given to illustrate how tracing can help find bugsespecially when a program runs without any runtime errors, but the results are incorrect. It also is useful to find errors quickly when the program crashes with an error message or just hangs up, leaving the programmer with no option but to kill the program and reboot the computer, over and over, until the bug is found.
Chapter 4 applies the basic principles of tracing to more advanced C++ constructs, such as strings, pointers, structs, and classes.
Chapter 5 illustrates how to use a debugger effectively as follow-on to the tracing method discussed in Chapters 3 and 4. Most compilers come with debuggers now, and students need to be able to use them at some point during their first course in programming. We strongly recommend learning to use both tracing and the debugger as alternative approaches.
The appendices give a summary of the most common bugs found in first C++ programs and a checklist of techniques for error detection and prevention. The examples in this book conform to the 1998 ISO/ANSI C++ standard.
Who should read this book?Beginning programmers should benefit from this book because it is a quick read with many simple examples, both numeric and non-numeric. It should save them many frustrating hours of debugging time when they apply the tracing and system debugger techniques illustrated in Chapters 3 to 5. Furthermore, anyone using this book can easily read any chapter independently of the others. This should also appeal to the more experienced programmers who want to review their knowledge of debugging without wading through all the fundamentals. Instructors in introductory programming classes may want to recommend this book to their students, because it will make them much more self sufficient, and it will greatly reduce the time they need for individual counseling for their programs.
How to use this bookBeginning programmers should read Chapters 1 and 2 to get a quick overview of the basic types of errors programmers tend to make. Chapters 3 and 4 are self-contained discussions of how to use tracing in your programs with a minimum of effort. Chapter 5 is more advanced and may be used later, when you feel the need for more debugging options, especially for larger programs.