Debugging a program involves several steps:
1.Correct all warnings and errors that the compiler finds. Many programmers assume that the default error level is enough. This is incorrect—set the error level as high as possible. Correct all warnings and errors, or understand why you do not have to correct them.
2.After the program compiles without warnings or errors, the real debugging takes place. Use the program and make sure that it performs as you expect. This process, called alpha testing, may take some time. The more problems you find and correct, however, the fewer the user will find.
3.After finding and correcting problems during the alpha testing, find a few qualified users to test the program in an environment as close as possible to that which the program will be used in. This testing is called beta testing. Make sure that the testers really use the program. Generally, beta testers get a free copy of the product for their effort.
4.After beta testing, the product should be bug free. Any problems found by you (in alpha testing) and your test users (in beta testing) should be corrected. Beta testers often test two or three versions of the product.
5.Now that the product is finished, you ship it. Remember the first customer’s name, because this is the person who finds the first bug, usually within a few minutes of using the product. Find ways to minimize the bug’s effect. After the product has been used for a few months, create an updated version that corrects all the bugs the users have discovered.
The first part of debugging is finding the errors, the second part is correcting them, and the third and final part is ensuring the correction does not create new errors.
Common Bugs
Following are some of the most common errors made when programming in C:
•Using uninitialized variables
•Misusing the assignment and equality operators
•Unexpected side effects
•Misuse of global variables