Adding code from p.37 of Head First C.