Preprocessor Directives in C
C - Preprocessor Directives - Definition and Usage
- In C Language preprocessor is more or less the own language which can be a very powerful tool to the programmer .
- All the preprocessor directives or commands begin with “#” .
- Below is the list of preprocessor directives that C language offers .
C Preprocessors #define - Definition and Usage
- In C Language, the #define directive allows the definition of macros within your source code.
- These macro definitions allow constant values to be declared for use throughout your code.
- This macro defines constant value and can be any of the basic data types..
C Preprocessors #ifdef - Definition and Usage
- If the value of expression is true, then the code that immediately follows the command will be compiled.
- “#ifdef” directive checks whether the particular macro is defined or not.
C Preprocessors #ifndef #endif - Definition and Usage
- #ifndef exactly acts as reverse as #ifdef directive.
- If particular macro is not defined, “If” clause statements are included in source file.
- Otherwise, else clause statements are included in source file for compilation and execution.
- #endif’ always matches the nearest ‘#ifdef’ (or ‘#ifndef’, or ‘#if’).
- Also, we cannot start a conditional group in one file and end it in another.
- The number of necessary #endif directives changes according to whether the elseif or #else directive is used.
C Type Casting - Definition and Usage
- In C- Programming the type casting is used to convert the variable from one datatype to another data type, after we perform casting the variable datatype will be changed.
- “stdlib.h” header file supports all the type casting functions in C language programing.