parenthesis and brace expression

本文详细解析了括号表达式和大括号表达式的运算规则,包括赋值表达式、判断表达式及其组合的求值过程。通过实例展示了不同类型表达式的返回值特性,强调了表达式末尾不可加逗号及分号的使用规范。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

parenthesis expression,as follows:

(exp1[, exp2[,...]])

it will return the last expression value.

expression may be assignment expression , judgment expression or both.

eg:

1.assignment expression:

c = (a=1,b =2)

the result is that c's value is 2.

2.judgment expression:

c = (a =1 , a==1)

the result is that c's value is 1.

3. both

c = (a = 1, (a != 1) && (a =2))

the result is that c's value is 0.

Note: after the last expression, it can‘t add comma.

brace expression, as follows:

{[exp1[;[exp2;[...]]]]}

if only having a expression without semicolon, it return the  value of expression.

c = { a = 12 };

the result is that c's value is 12.

if at least having two expression, and after every expression, you must add a semicolon. But it will return none.

{a=12;b =13;}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值