#define in C

Amansingh Javatpoint
1 min readJun 23, 2021

In the C programming language, the preprocessor directive acts an important role within which the #define directive is present that is used to define the constant or the micro substitution.

The #define directive can use any of the basic data types present in the C standard. The #define preprocessor directive lets a programmer or a developer define the macros within the source code.

This macro definition will allow the constant value that should be declared for the usage. Macro definitions cannot be changed within the program’s code as one does with other variables, as macros are not variables.

The #define is usually used in syntax that created a constant that is used to represent numbers, strings, or other expressions.

The #define directive should not be enclosed with the semicolon(;). It is a common mistake done, and one should always treat this directive as any other header file. Enclosing it with a semicolon will generate an error.

The #define creates a macro, which is in association with an identifier or is parameterized identifier along with a token string. After the macro is defined, then the compiler can substitute the token string for each occurrence of the identifier within the source file.

--

--