What is the difference between const and #define in C?

const#define
Has a data typeNo data type, only text
Handled by the compilerHandled by the preprocessor
Follows scope rulesValid from the line it is written
Has a memory addressNo address

Example: const int MAX = 10; and #define MAX 10. Prefer const (or enum) for plain values, because it is safer. See C Constants.


Learn more about the similar topics:
Tutorials
C Preprocessor and Macros
C File Handling
C Read From a File
C Command Line Arguments
Exercises & Assignments
No Content Found.
Interview Questions & Answers
What is the difference between const and #define in C?
What is the difference between #include with angle brackets and with double quotes in C?
What is the difference between a macro and a function in C?