Skip to main content Skip to navigation

3.1 Common errors

Below is a list of errors that probably everyone makes at some stage. You can always check over your code by using lint, and debug it using gdb or valgrind. Consult any book on C programming to find out more.

  • Putting a semicolon after a for/if/while etc statement
  • Using = instead of == when making comparisons
  • Not remembering about integer division (1/2 = 0!)
  • Running over by one element in your array (i.e., array elements number off from 0, not 1)
  • Assuming that when you declare a pointer, that this automatically creates a variable/array to point to!
  • Not matching your parentheses, or matching wrong type of parentheses (emacs does a parentheses check, so if you use emacs properly this shouldn't be an issue...