What is the difference between const and macro?
Answer:
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Answer:
- The const keyword is handled by the compiler, in another hand, a macro is handled by the preprocessor directive.
- const is a qualifier that is modified the behavior of the identifier but macro is preprocessor directive.
- There is type checking is occurred with const keyword but does not occur with #define.
- const is scoped by C block, #define applies to a file.
- const can be passed as a parameter (as a pointer) to the function. In the case of call by reference, it prevents to modify the passed object value.
need an explanation for this answer? contact us directly to get an explanation for this answer