Preprocessor introduction

Preprocessor directives are actually the instructions to the compiler itself.
They are operated directly by the compiler.

The most common preprocessor directives are:
  • include directive
  • define directive

include directive:
The include directive is used to include files.
Example :

#include <stdio.h>

Here, stdio.h is a header file and the preprocessor replace the above line with the contents of header file.

define directive :
It is used to assign names to different constants or statements which are to be used repeatedly in a program.
These defined values or statement can be used by main or in the user defined functions as well.

Preprocessing directive #define has two forms.
  • #define identifier token_string
  • Macros with argument
NOTE :
  • 1. Preprocessor statements begin with a hash symbol(#).
  • 2. Preprocessors are NOT terminated by a semicolon.

Post a Comment

0 Comments