I heard that if an expression is followed by a semicolon, then it is considered to be an expression statement.
Source: http://farside.ph.utexas.edu/teaching/329/lectures/node11.html
int x = 7;
x = 8;
x++;
x—-;
x = x << 1;
Run Code Online (Sandbox Code Playgroud)
这些都是表达式语句。
但这也是表达方式吗?
return 5;
Run Code Online (Sandbox Code Playgroud)
如果没有,请彻底解释原因。
如果您能说出返回饱和度是否也可以视为其他语言的表达语句,我也将不胜感激。
一个return语句和表达式语句是两回事。
C标准的 6.8.3节给出了表达式语句的语法:
表达声明:
- 表达选择
;
尽管第6.8.6节给出了return语句的语法:
跳转语句:
goto识别码;continue;break;return表达选择;
另外,这不是表达式语句(实际上根本不是语句):
int x = 7;
Run Code Online (Sandbox Code Playgroud)
但是一个宣言。