The C Pre processor or cpp is the macro pre-processor.
We can do below tasks using pre-processor directives.
- Including header files
- Expanding macro
- Conditional compilation
- Defining global constants.
Some examples of CPP directives are given below.
- #include<stdio.h> - This directive tells the CPP to include contents of stdio.h file into current c source file.
- #define PI 3.14 – This directive defines the constants.
We can also have directives that can be used for the
conditional compilation.
#include <stdio.h>
#include <stdlib.h>
#define PI 3.14
int main()
{
#if (defined PI)
printf(" PI is
defined");
#endif
}
No comments:
Post a Comment
Leave your valuable feedback. Your thoughts do matter to us.