[Previous] [Contents]


Sidebar 2 - C Coding Suggestions

For non-array "output" or "input/output" parameters, use local variables instead of dereferenced parameters in function calculations.
Use array notation instead of pointers and dereferencing when you're working with arrays.
When working with pointers in assignment statements, double-check that you're using the right level of indirection.
Unless you're positive a pointer has been initialized, check it for NULL before using it.
Use a new_string function to return new strings from functions.
Always check for a NULL return value after calling malloc.
Use the allocate macro to prevent memory "leakage."
Always initialize pointers in their definitions.
Use typedef and PTR, contents_of, and address_of macros to improve program readability.
Avoid popular, but tricky, C idioms for business application programming.
Don't use ++ or - in assignments.

[Previous] [Contents]