• A "bug" is a functional problem with your code. Your code
compiles, but in some way it does not solve the problem as it was
specified.
• Some common types of bugs:
– The program "crashes" (causes a "segmentation fault", on Linux)
– A loop does not seem to repeat.
– A loop does not repeat the right number of times (or loops forever)
– Results are calculated but look wrong.
• The more experience you get programming, the more you will learn
the typical programming errors that tend to produce these bugs.
• "Crashing" is usually caused by an illegal memory access - for
example leaving out the & in a sscanf statement, or using an array
name with an invalid subscript (out of bounds error), or using the
wrong format specifier with a printf or sscanf call
• Loops not repeating may be caused by an error in your
loop condition (e.g. using greater than instead of less
than), or an incorrect use of curly braces {} (maybe you
did not include the statements that you want repeated
inside the loop body), or putting a semi-colon after the
loop condition
for (i = 0; i < studentCount; i++); /* WRONG!!! */
• Loops not repeating the right number of times can be
due to errors in the loop logic, or using = in a condition
instead of ==, or possibly a failure to update the loop
counter variable.
• Bad values may be due to your forgetting to initialize
variables to known values (e.g. 0). They can also be due
to using the wrong type of format specifier in a sscanf
(e.g. %f to get an integer value).