从C11标准(§6.3.2.1左值,数组和功能指示符):为什么不能修改的左值具有数组类型?
A modifiable lvalue is an lvalue that does not have array type, does not have an incomplete type, does not have a const-qualified type, and if it is a structure or union, does not have any member (including, recursively, any member or element of all contained aggregates or unions) with a const-qualified type.
从下在果壳:
A modifiable lvalue is an lvalue that is not declared as a const -qualified “Type Qualifiers” on page 180), and that does not have an array type.
的原因是什么,一个修改的左值不能有数组类型?
是一个数组类型的对象总是隐const的?
您可以分配到可修改的左值;你不能分配给数组(只能分配给数组元素),所以数组名不能是可修改的左值。 –
谢谢。函数名称是否具有与数组名称类似的行为?但函数名称不是左值或非值。左值和非值都只能是一个对象表达式。 – Tim
在某些方面,函数名称就像数组名称;你当然不能分配给一个函数名 - 但你可以用它来调用一个函数或初始化一个函数指针。名称'可修改左值'的意思是你可以在赋值中使用'lvalue = rvalue;'。 –