[prev] 58 [next]

Fine Control

Good programming style often dictates ...
  • control loops only through termination condition
  • use if to control if only part of loop body needed
  • have one return per function
  • exit program only via return in main()
C has constructs to violate all of these
  • break and continue for fine loop control
  • multiple return statements within a function
  • exit and assert terminate program early
  • but, used carefully, can make code easier to understand