🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: vmsnet.internals
Article #337

Re: C Language question

#337
From: Arne Vajhxj
Date: Fri, 09 Oct 1992 11:40
27 lines
1738 bytes
> Question: in C, if one declares char a[I][J], is there anything in the
> language standard that guarantees that &a[0][0] is the first of a set of
> I*J contiguous chars, and that a[i+1][0] is guaranteed to be the same
> storage location as a[i][J] ).
>
> A friend asserts that it is, and says his experience on several systems
> 'proves' this. My belief is that there is nothing that says this will
> always be the case, and that the only constraint is that every valid pointer
> a[i] will point to J chars. Which of us is right?

I think your friend is rigth (a[I][J] would be I*J contigious bytes), but
I can not prove it, but ...

The arguments are:
  1)  As your friend has observed C-compilers tend to do it that way.
  2)  The creative way C lets you manipulate arrays, pointers and
      addresses must somehow assume, that they are stored contigious.
  3)  It is most efficient that way (simpler address calculations).

But to be absolutely certain you will need to check the real sources:
K&R and the ANSI specifications.

                                                          Arne

Arne Vajhxj                             local DECNET:  KO::ARNE
Computer Department                     PSI:           PSI%23831001304030::ARNE
Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK
Technical Details
Message-ID: <01GPQTVHA7W28WW0VG@kopc.hhs.dk>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!unogate!mvb.saic.com!macro32

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!unogate!mvb.saic.com!macro32
From: Arne Vajhxj <ARNE@ko.hhs.dk>
Newsgroups: vmsnet.internals
Subject: Re: C Language question
Message-ID: <01GPQTVHA7W28WW0VG@kopc.hhs.dk>
Date: 09 Oct 1992 12:40:54 +0100
Organization: Macro32<==>Vmsnet.Internals Gateway
X-Gateway-Source-Info: Mailing List
Lines: 28