C Coding Style
C Coding Style
Standards
• The purpose of having these standards is to facilitate sharing of each
other’s code, as well as to enable construction of tools (e.g., editors,
formatters). Through the use of these tools, programmers will be
helped in the development of their programs.
Naming Conventions
• Naming conventions make programs more understandable by making them easier
to read. They can also give information about the function of the identifier, e.g.,
constant, named type, that can be helpful in understanding the code.
• Variable and function names should be short yet meaningful.
Programming Practice
• Numerical constants should not be coded directly.
• The #define feature of the C preprocessor should be used to assign a
meaningful name.
• The enum data type is the preferred way to handle situations where a
variable takes on only a discrete set of values
• Use of goto is discouraged.
• Do not bury a variable initialization in the middle of a long declaration.
• Do not use multiple assignments, because it is hard to read,
• Don’t change C syntax via macro substitution,