Q:

How to redefine a Macro in C?

belongs to collection: C Preprocessors Programs

0

How to redefine a Macro in C?

The process to redefine a Macro is:

  1. Macro must be defined.
  2. When, you want to redefine the Macro, first of all, undefined the Macro by using #undef preprocessor directive.
  3. And, then define the Macro again by using #define preprocessor directive.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to check whether a Macro is defined or not in ... >>
<< Define a constant using Macro to use in Array decl...