Standards-12
Types and Constants

Use constants with the correct type [3 points each, 2% max]

  • Use 0 for an integer or real constant.

  • Use NULL for a pointer constant, not 0 or '\0'.

  • Use '\0' for a character constant, If you mean '0', write '0', not 48. If you mean '\n', write '\n', not 10. For example, if x is an integer from 0 to 9 then expression

      x + '0'
    
    yields the corresponding character (from '0' to '9'). Do not write
      x + 48
    
    It is much easier to read your program if your constants express what they really are.


Duplicate type definition [4 points each, 2% max]

Only define a type in one place, even if it is used in more than one module. If you need a type definition in more than one module, put the type definition in a header file that several modules can include.

Use correct presentation of types [3 points each, 1% max]

There are places where we use typedefs to give names to types. For example, you will write
  typedef int* ER;
which says that ER is a name for type int*. Anyplace where something should have type ER, write ER, not int*. Use the logical type name in preference to the physical type name. But do not use ER for int* in places where logical name ER is not appropriate.