Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the integer constant in C language?
What is the integer constant in C language?
Integer constant expression means that the operands in the expression are all integer types, and the integer types here are not only int types, but also char, (unsigned) short, (unsigned) long and so on. Operands in integer constant expressions have their values determined at compile time, so you only need to pay attention to which values are determined at compile time. This includes the following situations:

1.

A single character, such as "a" and "a"

2.

Single integer and expressions composed of integers, such as 123, 123+345.

3.

Enumeration constant

4.

Sizeof operation has a return value, such as sizeof(int).

5.

Null index value

6.

Address constant, such as 0X 12345678, and address constant plus an offset.

In C90 and C++, it is necessary to provide integer constant expressions when defining static arrays, such as INTA [10]; Therefore, you can simply try to define an array with expressions. If the array can be defined normally, it indicates that it is an integer expression.

In addition, in C, the const keyword does not mean that the variable it modifies is constant. It only means that the variable it modifies is read-only and cannot be modified. This is different from C++ because the const keyword in C++ can define an integer constant, so

const int size = 10;

Int array [size]; /* In C language, compilation failed, but in C++, you can use */