Overflowing an Array


If you attempt to access elements in an array, beyond the range you declared, this can lead to serious problems. You must make certain that all array operations are taking place within the bounds of the array. If you declare an array as int myarray[10], you must make sure you only attempt to access elements 0 through 9.

Overflowing the array is most likely to occur when using a pointer to an array, and then using an increment operator with the pointer. It is very easy to overlook the bounds of your array and find yourself pointing to some memory address that is outside the bounds of your array.




C++ Programming Fundamentals
C++ Programming Fundamentals (Cyberrookies)
ISBN: 1584502371
EAN: 2147483647
Year: 2005
Pages: 197
Authors: Chuck Easttom

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