How to use #ifndef #elif #else #endif conditional evaluation in C

1 Answer

0 votes
#include <stdio.h>
 
#define VAL 3
 
int main(void)
{
    #ifndef VAL
        printf("no\n");
    #elif VAL == 3
        printf("yes = 3\n");
    #else
        printf("no != 3\n");
    #endif
    
    return 0;
}

 
/*
run:

yes = 3

*/

 



answered Aug 23, 2016 by avibootz

Related questions

1 answer 142 views
1 answer 134 views
134 views asked Aug 23, 2016 by avibootz
1 answer 148 views
1 answer 259 views
1 answer 137 views
137 views asked Aug 23, 2016 by avibootz
1 answer 255 views
...