Magic Numbers
What is a preprocessor directive (macro)?
An instruction which tells the compiler to process them before the compilation of the program starts.
What is a "magic number"?
When constants are written into code.
How is a preprocessor directive written?
#define NAME REPLACEMENT
What will it do?
Before the program is compiled, it will find the NAME and replace it with another term.
What's another benefit of preprocessor directive?
If there is a change to the constant, instead of changing it throughout the entire code it can be changed in the preprocessor directive. This will cause it to change throughout the entire program.
Is this a good practice?
No, as it doesn't give a meaning as to why that particular number was used as opposed to another number.
What do they do?
They are a better way to create symbolic constants like numbers in a program. It gives the constant more meaning.
What's the convention for preprocessor directive?
Write that which is being replaced in CAPS, so people know that the constant.