开发者

How many expr_no_commas '=' expr_no_commas expressions are there in C?

开发者 https://www.devze.com 2023-02-17 19:32 出处:网络
expr_no_commas \'=\' expr_no_commas It\'s found in C\'s rule,but the only possible form I 开发者_StackOverflowcan think of is:
expr_no_commas '=' expr_no_commas

It's found in C's rule,but the only possible form I 开发者_StackOverflowcan think of is:

identifier = expr_no_commas

that is,the left side is a single variable,any other variants?


There a lot of C expressions that are assignments to non-identifiers; here are a few examples:

x[1] = 5;
*f() = 7;
*p++ = 0;
a[i].f = a[i].g;


Where did you find that "rule"? The syntax presented in the language standard (draft n1256, § 6.5.16) is

assignment-expression:
    conditional-expression
    unary-expression assignment-operator assignment-expression

assignment-operator: one of
    = *= /= %= += -= >= &= ^= |=

where unary-expression results in any number of productions that aren't simple identifiers (as Jeremiah Willcock has shown).

0

精彩评论

暂无评论...
验证码 换一张
取 消