I would like to know how the memory is allocated to #define variables in C.
#define VAR1 10
I have 2 questions...
In which memory segment VAR1 is stored?
In none of the segment.
VAR1 is relevant only in pre-processing stage and does not have any identity at run time. During pre-processing all instances of VAR1 are replaced with 10 so there is no memory requirement at run time because 10 is an integer literal.
What's the type of VAR1?
VAR1 is replaced with 10 at pre-processing stage. 10 being an integer literal, we can say type or VAR1 is int.
Moral: Macros are not variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With