Array name as a difference between the left and right values

  In simple terms, it appears in the assignment operator "=" is the right value on the right, appears in the assignment operator "=" is the value left on the left.

  For example, x = y.

  Left value: In this context, the compiler think it means x is the address of x represented . This address is only the compiler knows, at compile time to determine the compiler to save this address in a particular area, we do not have to consider where to save this address.

  Right value: In this context, the meaning of the compiler task y is the content of the address inside y represented . What this content is only if you know to run .

 

  Introducing a C-term - "left modifiable value." Means that appears on the left of the assignment operator address symbol represents the content must be modified. In other words, we can only be assigned to a non-read-only variables.

  

  Now that you have understood the difference between left and right values, then the following will discuss an array of circumstances as the left and right values.

  When the right time as a value representative of what the meaning of it? Many books considered to be the first address of the array, in fact, this is very wrong. a as the right value its meaning and & a [0] is the same, represents the first address of the array's first element , rather than the first address of the array (when used in expressions sizof (a), a represents is an array of name , and it not at this time is used as a rvalue), which are two different things. Note, however, this is only the representative, not a place (this is just simply think so, which is not too much to discuss specific implementation details) to store this address, that is, the compiler does not allocate a block of memory array to store its address, it will be very different with the pointer.

  It can not be left as a value ! This error is almost every student committed. The compiler will consider the meaning of the array name as the left value represents the first address of a first element, but this is a memory address of the beginning of a whole, we can only access an element of the array, the array can not be used as a general access. So we can put a [i] when the left value, and when the left can not put a value. In fact, we can put a variable as a general point of view, but this internal variable is divided into many small pieces, only to achieve the purpose of access to the whole of a variable are accessed through these pieces.

 

Guess you like

Origin www.cnblogs.com/doitjust/p/11318682.html