Low-level programming langauge originally part of Unix.
C is the lingua franca of the software world as so much is written in it. Any serious programmer should have significant familiarity with C.
C is worth learning as an aid to thinking about problems at the hardware and operating system levels - though it is still an abstract machine on top of the real hardware.
ANSI C89 compliant code is preferred for portability. Here are a few standard conventions:
/* */comment pairs, never
- no tabs, expand to spaces. 2 spaces per indentation level
- no whitespace after the keywords
- no braces around single-line blocks (e.g.,
- integer valued functions return -1 on error, 0 or positive on success
#defineed constants should be
Underscore_Capitalized, with matching typedefs
- function and variable names are compact like
underscore_lowercasedwhen clarity demands
- automatic variables (local variables inside a function) are never initialized at declaration
- don't write
!memcmp, etc.); always explicitly compare the result fo string or memory comparison with zero
- include files should not include other files (prevents circular dependencies and keeps compilation fast)
- Code should be readable and require few comments. Functions should have a line or two comment above explaining their purpose (even if redundant, as the purpose may not always be clear to others).
- Every field of a struct should have a corresponding comment
- Low-level code should be verbosely commented and when possible include links to reference materials. This can prevent a lot of wasteful churn between code, reference materials, and search engines when reading.
Last update on 7E4C11, edited 2 times. 2/2thh