📄 appa.html
字号:
<tt>a<b<c</tt> is parsed as <tt>(a<b)<c</tt>, and evaluates toeither 0 or 1.<p> <em>relational-expression</em>:<br> <em>shift-expression</em><br> <em>relational-expression</em> <tt><</tt> <em>shift-expression</em><br> <em>relational-expression</em> <tt>></tt> <em>shift-expression</em><br> <em>relational-expression</em> <tt><=</tt> <em>shift-expression</em><br> <em>relational-expression</em> <tt>>=</tt> <em>shift-expression</em><p>The operators <tt><</tt> (less), <tt>></tt> (greater), <tt><=</tt> (less or equal)and <tt>>=</tt> (greater or equal) all yield 0 if the specified relation isfalse and 1 if it is true. The type of the result is <tt>int</tt>. The usualarithmetic conversions are performed on arithmetic operands. Pointers toobjects of the same type (ignoring any qualifiers) may be compared; theresult depends on the relative locations in the address space of the pointed-toobjects. Pointer comparison is defined only for parts of the same object; iftwo pointers point to the same simple object, they compare equal; if thepointers are to members of the same structure, pointers to objects declaredlater in the structure compare higher; if the pointers refer to members of anarray, the comparison is equivalent to comparison of the the correspondingsubscripts. If <tt>P</tt> points to the last member of an array, then <tt>P+1</tt>compares higher than <tt>P</tt>, even though <tt>P+1</tt> points outside the array.Otherwise, pointer comparison is undefined.<p><dl><dd><font size="-1">These rules slightly liberalize the restrictions stated in the first edition,by permitting comparison of pointers to different members of a structure orunion. They also legalize comparison with a pointer just off the end of anarray.</font></dl><h3><a name="sa.7.10">A.7.10 Equality Operators</a></h3> <em>equality-expression</em>:<br> <em>relational-expression</em><br> <em>equality-expression</em> <tt>==</tt> <em>relational-expression</em><br> <em>equality-expression</em> <tt>!=</tt> <em>relational-expression</em><p>The <tt>==</tt> (equal to) and the <tt>!=</tt> (not equal to) operators areanalogous to the relational operators except for their lower precedence.(Thus <tt>a<b == c<d</tt> is 1 whenever <tt>a<b</tt> and <tt>c<d</tt>have the same truth-value.)<p>The equality operators follow the same rules as the relational operators,but permit additional possibilities: a pointer may be compared to a constantintegral expression with value 0, or to a pointer to <tt>void</tt>. See<a href="#sa.6.6">Par.A.6.6</a>.<h3><a name="sa.7.11">A.7.11 Bitwise AND Operator</a></h3> <em>AND-expression</em>:<br> <em>equality-expression</em><br> <em>AND-expression</em> <tt>&</tt> <em>equality-expression</em><p>The usual arithmetic conversions are performed; the result is the bitwiseAND function of the operands. The operator applies only to integral operands.<h3><a name="sa.7.12">A.7.12 Bitwise Exclusive OR Operator</a></h3> <em>exclusive-OR-expression</em>:<br> <em>AND-expression</em><br> <em>exclusive-OR-expression</em> <tt>^</tt> <em>AND-expression</em><p>The usual arithmetic conversions are performed; the result is the bitwiseexclusive OR function of the operands. The operator applies only to integraloperands.<h3><a name="sa.7.13">A.7.13 Bitwise Inclusive OR Operator</a></h3> <em>inclusive-OR-expression</em>:<br> <em>exclusive-OR-expression</em><br> <em>inclusive-OR-expression</em> <tt>|</tt> <em>exclusive-OR-expression</em><p>The usual arithmetic conversions are performed; the result is the bitwiseinclusive OR function of the operands. The operator applies only to integraloperands.<h3><a name="sa.7.14">A.7.14 Logical AND Operator</a></h3> <em>logical-AND-expression</em>:<br> <em>inclusive-OR-expression</em><br> <em>logical-AND-expression</em> <tt>&&</tt> <em>inclusive-OR-expression</em><p>The <tt>&&</tt> operator groups left-to-right. It returns 1 if both its operandscompare unequal to zero, 0 otherwise. Unlike <tt>&</tt>, <tt>&&</tt> guaranteesleft-to-right evaluation: the first operand is evaluated, including all sideeffects; if it is equal to 0, the value of the expression is 0. Otherwise,the right operand is evaluated, and if it is equal to 0, the expression'svalue is 0, otherwise 1.<p>The operands need not have the same type, but each must have arithmetic typeor be a pointer. The result is <tt>int</tt>.<h3><a name="sa.7.15">A.7.15 Logical OR Operator</a></h3> <em>logical-OR-expression</em>:<br> <em>logical-AND-expression</em><br> <em>logical-OR-expression</em> <tt>||</tt> <em>logical-AND-expression</em><p>The <tt>||</tt> operator groups left-to-right. It returns 1 if either of itsoperands compare unequal to zero, and 0 otherwise. Unlike <tt>|</tt>, <tt>||</tt>guarantees left-to-right evaluation: the first operand is evaluated, includingall side effects; if it is unequal to 0, the value of the expression is 1.Otherwise, the right operand is evaluated, and if it is unequal to 0, theexpression's value is 1, otherwise 0.<p>The operands need not have the same type, but each must have arithmetic typeor be a pointer. The result is <tt>int</tt>.<h3><a name="sa.7.16">A.7.16 Conditional Operator</a></h3> <em>conditional-expression</em>:<br> <em>logical-OR-expression</em><br> <em>logical-OR-expression</em> <tt>?</tt> <em>expression</em> <tt>:</tt> <em>conditional-expression</em><p>The first expression is evaluated, including all side effects; if it comparesunequal to 0, the result is the value of the second expression, otherwise thatof the third expression. Only one of the second and third operands isevaluated. If the second and third operands are arithmetic, the usualarithmetic conversions are performed to bring them to a common type, and thattype is the type of the result. If both are <tt>void</tt>, or structures orunions of the same type, or pointers to objects of the same type, the resulthas the common type. If one is a pointer and the other the constant 0, the 0is converted to the pointer type, and the result has that type. If one is apointer to <tt>void</tt> and the other is another pointer, the other pointer isconverted to a pointer to <tt>void</tt>, and that is the type of the result.<p>In the type comparison for pointers, any type qualifiers(<a href="#sa.8.2">Par.A.8.2</a>) in the type to which the pointer pointsare insignificant, but the result typeinherits qualifiers from both arms of the conditional.<h3><a name="sa.7.17">A.7.17 Assignment Expressions</a></h3>There are several assignment operators; all group right-to-left.<p> <em>assignment-expression</em>:<br> <em>conditional-expression</em><br> <em>unary-expression assignment-operator assignment-expression</em><p> <em>assignment-operator</em>: one of<br> <tt>= *= /= %= += -= <<= >>= &= ^= |=</tt><p>All require an lvalue as left operand, and the lvalue must be modifiable: itmust not be an array, and must not have an incomplete type, or be a function.Also, its type must not be qualified with <tt>const</tt>; if it is a structureor union, it must not have any member or, recursively, submember qualifiedwith <tt>const</tt>. The type of an assignment expression is that of its leftoperand, and the value is the value stored in the left operand after theassignment has taken place.<p>In the simple assignment with <tt>=</tt>, the value of the expression replacesthat of the object referred to by the lvalue. One of the following must betrue: both operands have arithmetic type, in which case the right operand isconverted to the type of the left by the assignment; or both operands arestructures or unions of the same type; or one operand is a pointer and theother is a pointer to <tt>void</tt>, or the left operand is a pointer and theright operand is a constant expression with value 0; or both operands arepointers to functions or objects whose types are the same except for thepossible absence of <tt>const</tt> or <tt>volatile</tt> in the right operand.<p>An expression of the form <tt>E1 <em>op</em>= E2</tt> is equivalent to<tt>E1 = E1 <em>op</em> (E2)</tt> except that <tt>E1</tt> is evaluated only once.<h3><a name="sa.7.18">A.7.18 Comma Operator</a></h3> <em>expression</em>:<br> <em>assignment-expression</em><br> <em>expression</em> <tt>,</tt> <em>assignment-expression</em><p>A pair of expressions separated by a comma is evaluated left-to-right, and thevalue of the left expression is discarded. The type and value of the result arethe type and value of the right operand. All side effects from the evaluationof the left-operand are completed before beginning the evaluation of theright operand. In contexts where comma is given a special meaning, for examplein lists of function arguments (<a href="#sa.7.3.2">Par.A.7.3.2</a>) and listsof initializers (<a href="#sa.8.7">Par.A.8.7</a>), the required syntactic unitis an assignment expression, so the comma operator appears only in aparenthetical grouping, for example,<pre> f(a, (t=3, t+2), c)</pre>has three arguments, the second of which has the value 5.<h3><a name="sa.7.19">A.7.19 Constant Expressions</a></h3>Syntactically, a constant expression is an expression restricted to a subsetof operators:<p> <em>constant-expression</em>:<br> <em>conditional-expression</em><p>Expressions that evaluate to a constant are required in several contexts:after <tt>case</tt>, as array bounds and bit-field lengths, as the value of anenumeration constant, in initializers, and in certain preprocessor expressions.<p>Constant expressions may not contain assignments, increment or decrementoperators, function calls, or comma operators; except in an operand of <tt>sizeof</tt>. If the constant expression is required to be integral, its operandsmust consist of integer, enumeration, character, and floating constants; castsmust specify an integral type, and any floating constants must be cast tointeger. This necessarily rules out arrays, indirection, address-of, andstructure member operations. (However, any operand is permitted for<tt>sizeof</tt>.)<p>More latitude is permitted for the constant expressions of initializers; theoperands may be any type of constant, and the unary <tt>&</tt> operator may beapplied to external or static objects, and to external and static arrayssubscripted with a constant expression. The unary <tt>&</tt> operator can alsobe applied implicitly by appearance of unsubscripted arrays and functions.Initializers must evaluate either to a constant or to the address of apreviously declared external or static object plus or minus a constant.<p>Less latitude is allowed for the integral constant expressions after<tt>#if</tt>; <tt>sizeof</tt> expressions, enumeration constants, and casts arenot permitted. See <a href="#sa.12.5">Par.A.12.5</a>.<h2><a name="sa.8">A.8 Declarations</a></h2>Declarations specify the interpretation given to each identifier; they do notnecessarily reserve storage associated with the identifier. Declarations thatreserve storage are called <em>definitions</em>. Declarations have the form<p> <em>declaration</em>:<br> <em>declaration-specifiers init-declarator-list<sub>opt</sub></em><tt>;</tt><p>The declarators in the init-declarator list contain the identifiers beingdeclared; the declaration-specifiers consist of a sequence of type and storageclass specifiers.<p> <em>declaration-specifiers</em>:<br> <em>storage-class-specifier declaration-specifiers<sub>opt</sub></em><br> <em>type-specifier declaration-specifiers<sub>opt</sub></em><br> <em>type-qualifier declaration-specifiers<sub>opt</sub></em><p> <em>init-declarator-list</em>:<br> <em>init-declarator</em><br> <em>init-declarator-list</em> <tt>,</tt> <em>init-declarator</em><p> <em>init-declarator</em>:<br> &nb
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -