A directive specifies how a compiler should process the input. The elif
preprocessor directive in C is equivalent to an else if
statement – it provides an alternate path of action when used with #if
, #ifdef
, or #ifndef
directives.
Execution enters the #elif
block when the #if
condition is false and the elif
condition holds true (this is shown below).
#elif conditional_expression
The
#elif
directive must be succeeded by the#endif
directive.
#include <stdio.h>#define checker 5int main(){#if checker <= 3printf("This is the if directive block.\n");#elif checker > 3printf("This is the elif directive block.\n");#endifreturn 0;}
Free Resources