#undef directive in C Language


#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 }


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

Solution Worked 0 UpvotesUpvote


Solution Didn't Worked 0 DownvotesDownvote



Play 2048 Game Online

Play Duckhunt Online

Need Help?

Looking for any Software or Tutorial?
Don't Worry, we will find it for you
Contact Now

Search Tags