Traditional Culture Encyclopedia - Traditional stories - C Language What is Expression

C Language What is Expression

The definition of a C expression is that a formula that joins the objects of an operation with C operators is called an expression.

C is more concise than other programming languages in terms of expression, such as self-subtraction, self-subtraction, comma operation and three-eye operation to make the expression more simple, but beginners often find this expression difficult to read, the key reason for this is that the operators and the order of operations do not understand the imperfect and incomplete.

When many different operations form a single expression, i.e., when there are multiple operators in a single expression, the order of precedence and the rules for combining the operations become very important.

Basic Components:

Data Types: C's data types include: integer, character, real or floating-point (single- and double-precision), enumeration, array, structure, ****-use, pointer, and null.

Constants and Variables: Constants have immutable values and symbolic constant names are usually capitalized.

Variables are quantities that are named after an identifier and whose value can be changed. An identifier is a sequence of letters, numbers, or underscores beginning with a letter or underscore; note that the first character must be a letter or underscore, otherwise it is an illegitimate variable name. Variables are allocated appropriate storage units at compile time.

Arrays: If a variable name is followed by a middle bracket with a number, the declaration is an array declaration. Strings are also a type of array. They end the array with an ASCII NULL. Pay special attention to the fact that the index value inside the middle bracket is counted from 0.

Pointers: If a variable is declared with a * sign in front of it, it indicates that it is a pointer-type variable. In other words, the variable stores an address, and the * (specifically, the unary operator *, hereinafter the same; in C, there is also the binaries operator *) is a content fetch operator, which means fetching the content stored in this memory address. Pointers are one of the main features of C that distinguish it from other high-level languages of the same generation.

Pointers can be not only the addresses of variables, but also the addresses of arrays, array elements, and functions. A pointer as a formal parameter can be used to get more than one return value during the call of a function, unlike return (z), which only gets one return value.

Strings: C strings are actually char-type arrays ending with the '\0' character, the use of character types do not need to refer to the library, but the use of strings will need to use the C standard library inside some of the functions used to operate on strings. They are different from character arrays. To use these functions you need to refer to the header file <string.h>.

File input/output: In C, input and output are implemented via a set of functions in the standard library. In ANSI C, these functions are defined in the header file <stdio.h>;.

Extended information:

p>Operational notation in C expressions:

Rather unusually, the bit-right (>>) operator can be either an arithmetic (highest valid bit complemented at the left end) or a logical (0 complemented at the left end) shift. For example, if you shift 11100011 by 3 bits, the arithmetic right shift becomes 11111100, and the logical right shift becomes 00011100. Since arithmetic right shifts are better suited to handling integers with negative signs, almost all compilers are arithmetic right shifters.

The operators, in descending order of precedence, are roughly: unary operators, arithmetic operators, relational operators, logical operators, conditional operators, assignment operators (=), and comma operators.

Reference:

Baidu Encyclopedia- C Language