Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is an integer constant expression in C language?
What is an integer constant expression in C language?

Integer constant expression means that the operands in the expression are all integer types. The integer type here is not only int type, but also includes char, (unsigned) short, (unsigned) long and other types. The operand in the integer constant expression has its value determined at compile time, so you only need to pay attention to which values ????are determined at compile time. This includes the following types Situation:

A single character,? such as 'A',?'a'

A single integer number and an expression composed of integer numbers, such as 123,?123?+? 345

Enum constants

There are values ??returned by the sizeof? operation, such as sizeof(int)

NULL pointer values

Address constant, such as 0X12345678, and address constant plus an offset

In C90 and C++, when defining a static array, you need to provide an integer constant expression. Such as int A[10 ]; Therefore, you can simply try to use an expression to define an array. 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 a constant. It only means that the variable modified by const is read-only and cannot be modified. This is different from C++. The const keyword in C++ You can define an integer constant, so

const?int?size?=?10;

int?array[size];?/*?In C language,?compile does not Pass,?Can pass in C++?*/