wenjianhn 发表于 2009-08-07 22:25

寥寥数语而已
http://c-faq-chn.sourceforge.net/ccfaq/node78.html

firocu 发表于 2015-05-25 16:27

本帖最后由 firocu 于 2015-05-25 17:43 编辑

回复 1# ypxing

4.4 s退化后为什么不可修改
这个问题的答案不能令人信服.
更为合理的答案, 我在c11中看到了, 这是一种语法上的规定:
Except when it is the operand of the sizeof operator, the _Alignof operator, or the
unary & operator, or is a string literal used to initialize an array, an expression that has
type ‘‘array of type’’ is converted to an expression with type ‘‘pointer to type’’ that points
to the initial element of the array object and is not an lvalue.
我觉得c11的文档指的应该是 is not a modifiable lvalue
因为An lvalue (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address).
而数组退化后的pointer在内存是有对应的值.
编译器这个警告, lvalue应该是指 需要一个modifiable lvalue:
error: lvalue required as increment operand

无论如何编译器给出了答案, 因为修改了不是modifiable lvalue的变量.

个人理解..

firocu 发表于 2015-05-25 16:28

我靠这都能碰到熟人啊.....回复 31# wenjianhn


   

奔跑的蜗牛aa 发表于 2015-12-25 23:06

值得学习!

奔跑的蜗牛aa 发表于 2015-12-25 23:08

值得学习!

dorodaloo 发表于 2015-12-26 19:18

还没看懂
,明天继续看

wenjianhn 发表于 2016-06-15 12:57

回复 33# firocu


    :mrgreen: Long time no see
页: 1 2 3 [4]
查看完整版本: [原创]数组与指针---都是"退化"惹的祸