Bugs and Debugging

Bugs. Ugh. Nobody likes them but every programmer will surely encounter them, regardless of how much experience he or she has. A bug is an error in our code, logical or otherwise, such that the behavior is not quite what we expect, whether it be that we allow inputs from users that cause our program to fail, that our program suffers a segmentation fault, or that our program crashes every time we run it. In this section, we explore techniques for rooting out bugs in our programs using certain tools, in particular eprintf(), a CS50 library function; help50, a command-line tool that helps us understand messages from clang and other tools; and debug50, a graphical debugger built upon a popular command-line debugger called gdb.