Tuesday, March 29, 2016

#Ifndef





It is a preprocessor keyword.

Normally it is used to add or delete some parts of code based on the inexistence of a certain           definition. 



Example 1 :- 


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <stdio.h>
#include <stdlib.h>
#define log
int main()
{
    int x =1 ;
    printf("%d\n",x);
    #ifndef log
    printf("Hello world!\n");
    #else
    printf("Hello Earth\n");
    #endif // log
    return 0 ;

}









Example 2 :- 


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int x =1 ;
    printf("%d\n",x);
    #ifndef log
    printf("Hello world!\n");
    #else
    printf("Hello Earth\n");
    #endif // log
    return 0 ;
}





Share this

0 Comment to "#Ifndef"

Post a Comment