Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
karthikeya Boyini

The #define is preprocessor directives. So when we define some macro using #define, it replaces into the code with its value before compilation. So when the compiler does not know anything about the code, in that time also the macro values are replaced.

The constant is actually a variable. By declaring this variable, it occupies memory unit. But we cannot update the value of constant type variable directly. We can change it using some pointer values.

Sometimes programmer may think that using macro is better than const, as this is not taking any additional space into the memory, but for some good compilers, the optimized code will not affect. They are very similar.

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.