Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the method of calculating array length in C language?
What is the method of calculating array length in C language?
Sizeof can be used to get the number of bytes occupied by a data type or variable in memory. Similarly, you can also use sizeof to get the number of bytes occupied by the whole array in memory. Because each element in the array is of the same type and occupies the same number of bytes in the memory, the total number of bytes divided by the number of bytes occupied by the elements is the length of the array.

More specifically, the bits are shifted to the right (>; >) operator can be an arithmetic shift (most significant bit on the left) or a logical shift (zero on the left). For example, if1111is shifted to the right by 3 digits, it will become11100 after arithmetic right shift, and the logic will be shifted to the right.

The priority of operators from high to low is monocular operator, arithmetic operator, relational operator, logical operator, conditional operator, assignment operator (=) and comma operator.

The characteristics of c language:

First, universality. The operating range of C language directly determines its advantages and disadvantages. C language contains 34 kinds of operators, so the operation range is incomparable to many other languages, and the expression forms of its operation results are also very rich.

Second, simplicity. Nine control statements and 32 keywords are the basic features of C language, which makes C language widely applicable in computer application programming. It can not only be suitable for programmers to operate and improve their work efficiency, but also support advanced programming and avoid the complexity of language switching.