as

Thursday, 13 November 2014

Pre-processor Directives in C


The C Pre processor or cpp is the macro pre-processor.

We can do below tasks using pre-processor directives.
  1. Including header files
  2. Expanding macro
  3. Conditional compilation
  4. Defining global constants.

Some examples of CPP directives are given below.
  1.  #include<stdio.h> - This directive tells the CPP to include contents of stdio.h file into current c source file.
  2.  #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.

Sponsored Links

Popular Posts

Comments

ShareThis