C-#ifndef .

In this session i have discussed #ifndef preprocessor in C .


The #ifndef preprocessor is used to check the constant or macro declared with #define . if yes it will execute the code .

The #ifdef and #ifndef perform same task .


Syntax

    #ifndef MACRO  
    statement  
    #endif  
    

Example : Write a program that demonstrate the use of #ifndef preprocessor .

    #include<stdio.h>
    #define PI 3.14
    int main()
    {
        #ifndef PI
        printf("Macro is already declared");
        #endif 
        return 0;
    }
    
    OUTPUT : Macro is already declared
    

Welcome to AndroidATPoint.

back image                     next image