[prev] 58 [next]

Sidetrack: C Style

We can define a symbolic constant at the top of the file

#define SPEED_OF_LIGHT 299792458.0
#define ERROR_MESSAGE "Out of memory.\n"

Symbolic constants make the code easier to understand and maintain

#define NAME replacement_text

  • The compiler's pre-processor will replace all occurrences of NAME with replacement_text
  • it will not make the replacement if NAME is inside quotes ("…") or part of another name