Character Input and Output

Chapter 9 - Arrays

Visual C++ 6: The Complete Reference
Chris H. Pappas and William H. Murray, III
  Copyright 1998 The McGraw-Hill Companies

Array Properties
There are four basic properties to an array:
  The individual data items in the array are called elements.
  All elements must be of the same data type.
  All elements are stored contiguously in the computer’s memory, and the subscript (or index) of the first element is zero.
  The name of the array is a constant value that represents the address of the first element in the array.
Since all elements of an array are assumed to be the same size, arrays cannot be defined by using mixed data types. Without this assumption, it would be very difficult to determine where any given element was stored. Since the elements are all the same size, and since that fact is used to help determine how to locate a given element, it follows that the elements are stored contiguously in the computer’s memory (with the lowest address corresponding to the first element, the highest address to the last element). This means that there is no filler space between elements and that they are physically adjacent in the computer.
It is possible to have arrays within arrays, that is, multidimensional arrays. Actually, if an array element is a structure (which will be covered in Chapter 13), then mixed data types can exist in the array by existing inside the structure member.
The name of an array represents a constant value that cannot change during the execution of the program. For this reason, arrays can never be used as lvalues. lvalues represent storage locations that can have their contents altered by the program; they frequently appear to the left of assignment statements. If array names were legal lvalues, your program could change their contents. The effect would be to change the starting address of the array itself. This may seem like a small thing, but some forms of expressions that might appear valid on the surface are not allowed. All programmers eventually learn these subtleties, but it helps if you understand why these differences exist.

Books24x7.com, Inc 2000 –  


Visual C++ 6(c) The Complete Reference
Visual Studio 6: The Complete Reference
ISBN: B00007FYGA
EAN: N/A
Year: 1998
Pages: 207

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net