gpt4 book ai didi

c - c 中间接运算符的右值

转载 作者:行者123 更新时间:2023-11-30 15:56:05 26 4
gpt4 key购买 nike

我对以下声明的工作感到困惑:

*ptr++->str

第一个 ++ 运算符应用于返回右值的 ptr。必须应用下一个运算符 ->-> 运算符不需要左值吗?

最佳答案

Doesnt -> operator require lvalue?

没有。请参阅 C99 标准第 6.5.2.3 节:

The first operand of the -> operator shall have type ‘‘pointer to qualified or unqualified structure’’ or ‘‘pointer to qualified or unqualified union’’, and the second operand shall name a member of the type pointed to.

...

A postfix expression followed by the -> operator and an identifier designates a member of a structure or union object. The value is that of the named member of the object to which the first expression points, and is an lvalue.

这就是关于此事的全部内容。

关于c - c 中间接运算符的右值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11492355/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com