C #undef
Example
#undef token
Let's explore a basic illustration of how to declare and remove a constant.
Example
Example
#include <stdio.h>
#define PI 3.14
#undef PI
main() {
printf("%f",PI);
}
Output:
Output
Compile Time Error: 'PI' undeclared
The #undef directive is employed to specify the preprocessor constant within a specific scope, allowing you to redefine the constant if needed.
Let's explore a scenario where we declare and then clear a numeric variable. Prior to its removal, this variable was referenced by another variable called square.
Example
Example
#include <stdio.h>
#define number 15
int square=number*number;
#undef number
main() {
printf("%d",square);
}
Output: