表达式语句 (C)Expression Statement (C)

在执行表达式语句时,将根据表达式和赋值中概述的规则来计算表达式。When an expression statement is executed, the expression is evaluated according to the rules outlined in Expressions and Assignments.

语法Syntax

expression-statement:expression-statement:
expression opt;expression opt;

在执行下一个语句前,完成表达式计算的所有副作用。All side effects from the expression evaluation are completed before the next statement is executed. 空表达式语句被称为 null 语句。An empty expression statement is called a null statement. 有关详细信息,请参阅 Null 语句See The Null Statement for more information.

这些示例演示了表达式语句。These examples demonstrate expression statements.

x = ( y + 3 );            /* x is assigned the value of y + 3  */  
x++;                      /* x is incremented                  */  
x = y = 0;                /* Both x and y are initialized to 0 */  
proc( arg1, arg2 );       /* Function call returning void      */  
y = z = ( f( x ) + 3 );   /* A function-call expression        */  

在最后一个语句中,函数调用表达式的值(包括函数返回的任何值)增加 3,然后被赋给变量 yzIn the last statement, the function-call expression, the value of the expression, which includes any value returned by the function, is increased by 3 and then assigned to both the variables y and z.

请参阅See Also

语句Statements