C - Preprocessors #Ifndef #Endif - ifndef
Learn C - C tutorial - Ifndef - C examples - C programs
C Preprocessors #ifndef #endif - ifndef - Definition and Usage
- #ifndef exactly acts as reverse as #ifdef directive.
- If particular macro is not defined, “If” clause statements are included in source file.
- Otherwise, else clause statements are included in source file for compilation and execution.
- #endif’ always matches the nearest ‘#ifdef’ (or ‘#ifndef’, or ‘#if’).
- Also, we cannot start a conditional group in one file and end it in another.
- The number of necessary #endif directives changes according to whether the elseif or #else directive is used.
C Syntax
#endif
- #endif’ always matches the nearest ‘#ifdef’ (or ‘#ifndef’, or ‘#if’).
- Also, we cannot start a conditional group in one file and end it in another.
- The number of necessary #endif directives changes according to whether the elseif or #else directive is used.
C Syntax
Sample - C Code
C Code - Explanation :
- In C programming #include<stdio.h> specifies a statement which tells the compiler to insert the contents of stdio at that particular place. A header file is a C file, that typically ends in ".h".In this example, #define wikitechy defines the constant name WIKITECHY.
- In this example, #ifndef wikitechy specifies the reverse of #ifdef directive.
- #define wiki specifies the directive, there by executing the #else statement.
- The command #else specifies the else statement and prints the statement www.wikitechy.com.
- In this example, #endif specifies the end of the program.
Sample Output - Programming Examples
- Here in this output the “www.wikitechy.com” is printed in the console window since the #else directive has been defined.