#undef directive in C Language

[3200 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



Search
New Year Deals End in










Recommended Quiz
Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Search Tags

    Everything about undef directive

    example of undef directive in C