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 125 views
1 answer 127 views
127 views asked Aug 23, 2016 by avibootz
1 answer 141 views
1 answer 248 views
1 answer 131 views
131 views asked Aug 23, 2016 by avibootz
1 answer 243 views
...