In C programming, preprocessor directives are special lines beginning with # that are processed by the preprocessor before actual compilation. These directives provide instructions to the preprocessor to perform various tasks like including header files, defining constants, and conditional compilation. Here are the main types of preprocessor directives.
Include Directive (#include):Includes the contents of a file into the source code at the point where the directive appears.
Define Directive (#define): Defines a macro, which is a name representing a sequence of characters, which can be a value, an expression, or a statement.
Undef Directive (#undef): Undefines a previously defined macro.
Conditional Directive (#if, #ifdef, #ifndef, #else, #elif, #endif): These directives are used for conditional compilation based on certain conditions.
Error Directive (#error): Causes the preprocessor to generate an error message during compilation.
Pragma Directive (#pragma):Provides additional instructions to the compiler, typically used for optimization or platform-specific directives.
Program:
Program.c
Resources :
Test Your Knowledge
Choose The
With supporting text below as a natural lead-in to additional content.