#define and const both are used in C Programming Language for defining constants.
The #define directive is a preprocessor directive; the preprocessor directive replaces the macros by their body before the compilation is started.
Now in your c program if you use
This code would get converted into
A const variable declaration actually declares an actual variable in the language, which you can use like a normal variable but its value cannot be changed once assigned. You can use const normally like another variable to pass it around to another variable, cast it to some another type, convert it, etc.
|#define directive is a preprocessor directive.||const variable is just like a normal variable in C language.|
|#define can only define simple constant.||const can define complex constants too.|
|Syntax check will not be done for #define until the error macro is used in code block. Example:
||Syntax check will be done for const|
|#define is not type-safe.||const is type safe|
Looking for any Software or Tutorial?
Don't Worry, we will find it for you