2. Symbolic constant: replace it with numerical constant with #define, which only exists at compile time. take for example
# Define a 5
A symbolic constant A is defined, and the preprocessor will replace it with 5 at compile time.
3. Constant data type:
For example, define an int constant: const int a = 5;; , where is const int type. When the type is decorated with const, the compiler will treat the behavior of modifying this data as a compilation error. Therefore, const data is used as a constant.
There are also literal quantities of characters/strings: characters/strings like' a' or' AAA' are literal quantities. Literal quantity is not a constant in C language (it is a constant in C++), because the operation of modifying its content is defined as "undefined behavior" in C language standard, and the modification operation may lead to uncertain consequences. If the contents of the contract are not modified by pointers, the amount of words can be used as a constant. Modifying the pointer with the previous const can restrict the pointer from modifying its content. For example, const char * str = "aa pointer str points to something that cannot be modified by str, and what STR points to can be regarded as a constant string. The amount of text replaced by #define is anonymous and can also be used as a constant.
====
[Original answer group]
If it helps you, please remember to adopt it as a satisfactory answer, thank you! Wish you a happy life!