--- In [email protected], Ana M <ana_dprinc...@...> wrote: > > I have been reading everywhere that "all arrays consist of > contiguous memory locations." > > Here, what does contiguous mean?
<http://www.merriam-webster.com/dictionary/contiguous> > Does it mean that it is possible that the elements > of the array need not be compulsorily in the adjacent memory > locations? I'm not sure what that means, but I'd guess no. ;) > i.e., suppose I declare an array of integers in the following > way, and assuming int occupies 2 bytes, > int a[5]; > > then is it possible that the memory allocation can also be in > the following way: > > index 0 1 2 3 4 > address 1000 1002 1004 1050 1052 No. > or should it be compulsorily continuous > > index 0 1 2 3 4 > address 1000 1002 1004 1006 1008 Yes, although I discourage you from thinking in terms of raw address values. C is an abstract language. > And if it should be compulsorily continuous, then why is it > given everywhere that array elements are stored in contiguous > memory locations. Think about how you would implement pointer arithmetic if the memory wasn't sequential. -- Peter
