C Control StatementsC FunctionsC ArrayC PointerC Dynamic MemoryC StringC MathC StructureC UnionC File HandlingC PreprocessorC Command LineC Misc |
Preprocessor Directive in cThe preprocessor scans and modifies the source code before the compilation. The main function performed by the preprocessor are
1. Simple macro substitution. Advantage of using Preprocessor
1. program modification easy Any start line start with # symbol known as preprocessor directives. When the preprocessor find the line start with a # symbol, it consider that the line is a command for itself and works according So all the directives executed by the preprocessor , and compiler does not read any line starting with # symbol. List of all preprocessor Directives
#define c define The general syntax is: #define macro_name macro_expression The macro_name is any valid C identifier. and it is write generally in capital letters to distinguish it from others variable The macro_expansion can be any text. There should be space necessary between macro name and macro expansion. The C preprocessor replaces all the occurrences of the micro_name with the macro_expansion let us take some examples of #define directive
#define FALSE 0 #include The processor directive #include is used to include a file into the source code of program. we used this in the program to include header files. The file name should be between angle brackets. The syntax is
#include< filename > The after including the file by #include the complete content of the file can be used in the program. when the filename is with in the angle brackets, then the file is searched in the standard include directory only #else and #elif in c #else is used with the #if preprocessor directive. It is like if-else control structure. The syntax is as-
if the constant expression is true(non zero) then the statements between #if and #else are compiled otherwise the statements between #else and #endlif are compiled lets take the example to understand #else directive
|