The instructions that are given to the compiler before the beginning of the actual program are called preprocessor directives. These arte also called compiler directives. These are written at the beginning of the source program. These preprocessor directives start with a number sign (#) and the key word “include” or “define”.
These are the instructions or directives that tell the compiler to take the actions before compiling the source program. The program that handles the preprocessor directives is called the preprocessor because it does some processing before the compilation process actually starts.
There are two types of pre-processor in C language.
The # include directive: -
The # include is a pre-processor directive. It is used to include or import a source text into source program. It is usually used to import header files into a program.
The syntax to use the # include directive is:
# include
Giving the name of the header file in angle brackets specifies that the file is located in the include directory of the compiler program.
The name of the file to be imported can also be written in double quotes. When the name of the file is written in double quotes, it specifies that the file is to be loaded from the directory which contains the source program file.
The syntax to include a header file is:
# include “name of the header file”
The # define directive: -
The # define is a pre-processor directive. It is used to assign a constant quantity to an identifier. This directive can be used any where in the program. Its syntax is:
# define identifier constant
Where
Identifier specifies the identifier name to which the constant value is to be assigned.
Constant specifies the constant value that is to be assigned to the identifier.
The identifier specified in the define directive is not a variable. It does not have any data type. The pre-processor simply replaces all occurrences of the identifier with its value in the program statements that follow the directive.
Posted by: Wasim Javed
No comments:
Post a Comment