On Sat, 10 Apr 1999, Dan Jue wrote:
# Are we allowed to assume that row-major order arrays are totally
# contiguous in memory for any platform (by your example of address
Probably not.
# a[0][4])? For arrays of structures or objects (or some other big unit),
# is it not possible for their locations in memory to be non-contiguous?
Yes.
# Also i'm assuming that you cannot access a[0][4] directly because wouldn't
# that cause an out-of-bound subscript error? So you would instead do some
No. C Does not do array bounds checking. You could quite happily run this
C program:
main(){int f[2]; f[12345]=1;}
and when you run it all you get is an ever helpful 'Bus Error'.
# manual pointer arithmetic to get that address, right?
a[0][4] is a legal array subscript. If the element you're telling it to
reference is part of the array then nothing bad will happen, if however the
array isn't stored contiguously then you may try and access memory you have
no rights to access and crash the program.
# Thanx for any response.
#
#
# Best Regards,
#
# <*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*>
# <*> Dan Jue, CMSC UMCP <*> Linux '99 <*>
# <*> <*> ReSiTaNcE iS FuTiLe! <*>
# <*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*>
#
#
#
--
+++ If at first you don't succeed, you must be a programmer +++
[EMAIL PROTECTED] http://www.penguinpowered.com/~a_out