📄 appa.html
字号:
parameters of the function's prototype. The number of arguments must be thesame as the number of explicitly described parameters, unless the declaration'sparameter list ends with the ellipsis notation <tt>(, ...)</tt>. In that case,the number of arguments must equal or exceed the number of parameters; trailingarguments beyond the explicitly typed parameters suffer default argumentpromotion as described in the preceding paragraph. If the definition of thefunction is old-style, then the type of each parameter in the definition, afterthe definition parameter's type has undergone argument promotion.<p><dl><dd><font size="-1">These rules are especially complicated because they must cater to a mixtureof old- and new-style functions. Mixtures are to be avoided if possible.</font></dl><p>The order of evaluation of arguments is unspecified; take note that variouscompilers differ. However, the arguments and the function designator arecompletely evaluated, including all side effects, before the function isentered. Recursive calls to any function are permitted.<h4><a name="sa.7.3.3">A.7.3.3 Structure References</a></h4>A postfix expression followed by a dot followed by an identifier is a postfixexpression. The first operand expression must be a structure or a union, andthe identifier must name a member of the structure or union. The value is thenamed member of the structure or union, and its type is the type of the member.The expression is an lvalue if the first expression is an lvalue, and if thetype of the second expression is not an array type.<p>A postfix expression followed by an arrow (built from <tt>-</tt> and <tt>></tt>)followed by an identifier is a postfix expression. The first operandexpression must be a pointer to a structure or union, and the identifier mustname a member of the structure or union. The result refers to the named memberof the structure or union to which the pointer expression points, and the typeis the type of the member; the result is an lvalue if the type is not an arraytype.<p>Thus the expression <tt>E1->MOS</tt> is the same as <tt>(*E1).MOS</tt>.Structures and unions are discussed in <a href="#sa.8.3">Par.A.8.3</a>.<p><dl><dd><font size="-1">In the first edition of this book, it was already the rule that a member namein such an expression had to belong to the structure or union mentioned inthe postfix expression; however, a note admitted that this rule was not firmlyenforced. Recent compilers, and ANSI, do enforce it.</font></dl><h4><a name="sa.7.3.4">A.7.3.4 Postfix Incrementation</a></h4>A postfix expression followed by a <tt>++</tt> or <tt>--</tt> operator is a postfixexpression. The value of the expression is the value of the operand. After thevalue is noted, the operand is incremented <tt>++</tt> or decremented <tt>--</tt>by 1. The operand must be an lvalue; see the discussion of additive operators(<a href="#sa.7.7">Par.A.7.7</a>) and assignment (<a href="#sa.7.17">Par.A.7.17</a>)for further constraints on the operand and details of the operation. The resultis not an lvalue.<h3><a name="sa.7.4">A.7.4 Unary Operators</a></h3>Expressions with unary operators group right-to-left.<p> <em>unary-expression</em>:<br> <em>postfix expression</em><br> <tt>++</tt><em>unary expression</em><br> <tt>--</tt><em>unary expression</em><br> <em>unary-operator cast-expression</em><br> <tt>sizeof</tt> <em>unary-expression</em><br> <tt>sizeof</tt>(<em>type-name</em>)</em><p> <em>unary operator:</em> one of<br> <tt>& * + - ~ !</tt><h4><a name="sa.7.4.1">A.7.4.1 Prefix Incrementation Operators</a></h4>A unary expression followed by a <tt>++</tt> or <tt>--</tt> operator is a unaryexpression. The operand is incremented <tt>++</tt> or decremented <tt>--</tt>by 1. The value of the expression is the value after the incrementation(decrementation). The operand must be an lvalue; see the discussion ofadditive operators (<a href="#sa.7.7">Par.A.7.7</a>) and assignment(<a href="#sa.7.17">Par.A.7.17</a>) for further constraintson the operands and details of the operation. The result is not an lvalue.<h4><a name="sa.7.4.2">A.7.4.2 Address Operator</a></h4>The unary operator <tt>&</tt> takes the address of its operand. The operand mustbe an lvalue referring neither to a bit-field nor to an object declared as<tt>register</tt>, or must be of function type. The result is a pointer to theobject or function referred to by the lvalue. If the type of the operand is<em>T</em>, the type of the result is ``pointer to <em>T</em>.''<h4><a name="sa.7.4.3">A.7.4.3 Indirection Operator</a></h4>The unary <tt>*</tt> operator denotes indirection, and returns the object orfunction to which its operand points. It is an lvalue if the operand is apointer to an object of arithmetic, structure, union, or pointer type. If thetype of the expression is ``pointer to <em>T</em>,'' the type of the result is<em>T</em>.<h4><a name="sa.7.4.4">A.7.4.4 Unary Plus Operator</a></h4>The operand of the unary <tt>+</tt> operator must have arithmetic type, and theresult is the value of the operand. An integral operand undergoes integralpromotion. The type of the result is the type of the promoted operand.<p><dl><dd><font size="-1">The unary <tt>+</tt> is new with the ANSI standard. It was added for symmetrywith the unary <tt>-</tt>.</font></dl><h4><a name="sa.7.4.5">A.7.4.5 Unary Minus Operator</a></h4>The operand of the unary <tt>-</tt> operator must have arithmetic type, and theresult is the negative of its operand. An integral operand undergoes integralpromotion. The negative of an unsigned quantity is computed by subtractingthe promoted value from the largest value of the promoted type and adding one;but negative zero is zero. The type of the result is the type of the promotedoperand.<h4><a name="sa.7.4.6">A.7.4.6 One's Complement Operator</a></h4>The operand of the <tt>~</tt> operator must have integral type, and the resultis the one's complement of its operand. The integral promotions are performed.If the operand is unsigned, the result is computed by subtracting the valuefrom the largest value of the promoted type. If the operand is signed, theresult is computed by converting the promoted operand to the correspondingunsigned type, applying <tt>~</tt>, and converting back to the signed type. Thetype of the result is the type of the promoted operand.<h4><a name="sa.7.4.7">A.7.4.7 Logical Negation Operator</a></h4>The operand of the <tt>!</tt> operator must have arithmetic type or be a pointer,and the result is 1 if the value of its operand compares equal to 0, and 0otherwise. The type of the result is <tt>int</tt>.<h4><a name="sa.7.4.8">A.7.4.8 Sizeof Operator</a></h4>The <tt>sizeof</tt> operator yields the number of bytes required to store anobject of the type of its operand. The operand is either an expression, whichis not evaluated, or a parenthesized type name. When <tt>sizeof</tt> is appliedto a <tt>char</tt>, the result is 1; when applied to an array, the result is thetotal number of bytes in the array. When applied to a structure or union, theresult is the number of bytes in the object, including any padding required tomake the object tile an array: the size of an array of <em>n</em> elements is <em>n</em>times the size of one element. The operator may not be applied to an operandof function type, or of incomplete type, or to a bit-field. The result is anunsigned integral constant; the particular type is implementation-defined. Thestandard header <tt><stddef.h></tt> (See <a href="appb.html">appendix B</a>) defines thistype as <tt>size_t</tt>.<h3><a name="sa.7.5">A.7.5 Casts</a></h3>A unary expression preceded by the parenthesized name of a type causesconversion of the value of the expression to the named type.<p><em> cast-expression:<br> unary expression<br> (type-name) cast-expression</em><p>This construction is called a <em>cast</em>. The names are described in <a href="#sa.8.8">Par.A.8.8</a>.The effects of conversions are described in <a href="#sa.6">Par.A.6</a>. An expressionwith a cast is not an lvalue.<h3><a name="sa.7.6">A.7.6 Multiplicative Operators</a></h3>The multiplicative operators <tt>*</tt>, <tt>/</tt>, and <tt>%</tt> groupleft-to-right.<p> <em>multiplicative-expression</em>:<br> <em>multiplicative-expression</em> <tt>*</tt> <em>cast-expression</em><br> <em>multiplicative-expression</em> <tt>/</tt> <em>cast-expression</em><br> <em>multiplicative-expression</em> <tt>%</tt> <em>cast-expression</em><p>The operands of <tt>*</tt> and <tt>/</tt> must have arithmetic type; the operands of<tt>%</tt> must have integral type. The usual arithmetic conversions are performedon the operands, and predict the type of the result.<p>The binary <tt>*</tt> operator denotes multiplication.<p>The binary <tt>/</tt> operator yields the quotient, and the <tt>%</tt> operator theremainder, of the division of the first operand by the second; if the secondoperand is 0, the result is undefined. Otherwise, it is always true that<tt>(a/b)*b + a%b</tt> is equal to <tt>a</tt>. If both operands are non-negative, thenthe remainder is non-negative and smaller than the divisor, if not, it isguaranteed only that the absolute value of the remainder is smaller than theabsolute value of the divisor.<h3><a name="sa.7.7">A.7.7 Additive Operators</a></h3>The additive operators <tt>+</tt> and <tt>-</tt> group left-to-right. If the operandshave arithmetic type, the usual arithmetic conversions are performed. There aresome additional type possibilities for each operator.<p> <em>additive-expression</em>:<br> <em>multiplicative-expression</em><br> <em>additive-expression</em> <tt>+</tt> <em>multiplicative-expression</em><br> <em>additive-expression</em> <tt>-</tt> <em>multiplicative-expression</em><p>The result of the <tt>+</tt> operator is the sum of the operands. A pointer toan object in an array and a value of any integral type may be added. The latteris converted to an address offset by multiplying it by the size of the objectto which the pointer points. The sum is a pointer of the same type as theoriginal pointer, and points to another object in the same array, appropriatelyoffset from the original object. Thus if <tt>P</tt> is a pointer to an object inan array, the expression <tt>P+1</tt> is a pointer to the next object in thearray. If the sum pointer points outside the bounds of the array, except atthe first location beyond the high end, the result is undefined.<p><dl><dd><font size="-1">The provision for pointers just beyond the end of an array is new.It legitimizes a common idiom for looping over the elements of an array.</font></dl><p>The result of the <tt>-</tt> operator is the difference of the operands. A valueof any integral type may be subtracted from a pointer, and then the sameconversions and conditions as for addition apply.<p>If two pointers to objects of the same type are subtracted, the result is asigned integral value representing the displacement between the pointed-toobjects; pointers to successive objects differ by 1. The type of the result isdefined as <tt>ptrdiff_t</tt> in the standard header <tt><stddef.h></tt>.The value is undefined unless the pointers point to objects within the same array;however, if <tt>P</tt> points to the last member of an array, then <tt>(P+1)-P</tt>has value 1.<h3><a name="sa.7.8">A.7.8 Shift Operators</a></h3>The shift operators <tt><<</tt> and <tt>>></tt> group left-to-right.For both operators, each operand must be integral, and is subject to integralthe promotions. The type of the result is that of the promoted left operand.The result is undefined if the right operand is negative, or greater than orequal to the number of bits in the left expression's type.<p> <em>shift-expression</em>:<br> <em>additive-expression</em><br> <em>shift-expression</em> <tt><<</tt> <em>additive-expression</em><br> <em>shift-expression</em> <tt>>></tt> <em>additive-expression</em><p>The value of <tt>E1<<E2</tt> is <tt>E1</tt> (interpreted as a bit pattern)left-shifted <tt>E2</tt> bits; in the absence of overflow, this is equivalentto multiplication by 2<sup>E2</sup>. The value of <tt>E1>>E2</tt> is <tt>E1</tt>right-shifted <tt>E2</tt> bit positions. The right shift is equivalent todivision by 2<sup>E2</sup> if <tt>E1</tt> is unsigned or it has a non-negativevalue; otherwise the result is implementation-defined.<h3><a name="sa.7.9">A.7.9 Relational Operators</a></h3>The relational operators group left-to-right, but this fact is not useful;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -