Programming Practice – Defensive Programming

add code to handle

  • unexcepted cases
  • illegal/incorrect data
  • error return

pre-conditions: input range

post-conditions: output range

can check using assert()  function #include <assert.h>

common error

  • == writen as =
    • wirte constant == variable , not variable == constant

留下评论