Home »
C programs »
C preprocessors programs
How to redefine a Macro in C?
Here, we are going to learn how to redefine a defined Macro in C programming language? To redefine a Macro, first we undefined the Macro and then define the Macro.
By IncludeHelp Last updated : March 10, 2024
Redefining a Macro in C
The process to redefine a Macro is:
- Macro must be defined.
- When, you want to redefine the Macro, first of all, undefined the Macro by using #undef preprocessor directive.
- And, then define the Macro again by using #define preprocessor directive.
Example
#include <stdio.h>
#define NUM 100
int main()
{
//printing the value of NUM
printf("NUM: %d\n", NUM);
//redefining the Macor: NUM
#undef NUM
#define NUM 200
//printing the value of NUM
printf("NUM: %d\n", NUM);
return 0;
}
Output
NUM: 100
NUM: 200
C Preprocessors Programs »