Tuesday, March 29, 2016

#Ifdef



Ifdef normally it is used to add or delete some parts of code based on the existence of a certain definition . 


Example :


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



Share this

0 Comment to "#Ifdef"

Post a Comment