#undef directive in C Language

[7776 views]




#undef directive is used in C to undefine a macro that has been defined previously using #define. It is used if any macro defined earlier is not needed or if the macro needs to redefined.

undef preprocessor directive in C

#undef directive Syntax:

#undef SAMPLE

The above code would remove the macro definition named SAMPLE.

#undef directive example in C

#include <stdio.h> #define NUM 33 void main() { int a = NUM; printf("Value of a: %d\n", a); #undef NUM // undefining macro NUM #ifdef NUM printf("NUM macro defined\n"); // this part is ignored as NUM is undefined #else printf("macro NUM is Undefined\n"); #endif }

Output

jp@jp-VirtualBox:~/cpgms/preprocessor$ ./a.out Value of a: 33 macro NUM is Undefined
                 





Comments










Best Search Engine:

Sponsored Deals ends in



Thinking of Buying Products Online??

Use Below Search to get Best Discounts Online

Interesting Technical Quizzes:

Online Browser Games:
     



Search Tags

    Everything about undef directive

    example of undef directive in C