home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / vmsnet / internal / 1425 < prev    next >
Encoding:
Internet Message Format  |  1992-10-09  |  1.7 KB

  1. Path: sparky!uunet!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!unogate!mvb.saic.com!macro32
  2. From: Arne Vajhxj <ARNE@ko.hhs.dk>
  3. Newsgroups: vmsnet.internals
  4. Subject: Re: C Language question
  5. Message-ID: <01GPQTVHA7W28WW0VG@kopc.hhs.dk>
  6. Date: 09 Oct 1992 12:40:54 +0100
  7. Organization: Macro32<==>Vmsnet.Internals Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 28
  10.  
  11. > Question: in C, if one declares char a[I][J], is there anything in the
  12. > language standard that guarantees that &a[0][0] is the first of a set of
  13. > I*J contiguous chars, and that a[i+1][0] is guaranteed to be the same
  14. > storage location as a[i][J] ).
  15. >
  16. > A friend asserts that it is, and says his experience on several systems
  17. > 'proves' this. My belief is that there is nothing that says this will
  18. > always be the case, and that the only constraint is that every valid pointer
  19. > a[i] will point to J chars. Which of us is right?
  20.  
  21. I think your friend is rigth (a[I][J] would be I*J contigious bytes), but
  22. I can not prove it, but ...
  23.  
  24. The arguments are:
  25.   1)  As your friend has observed C-compilers tend to do it that way.
  26.   2)  The creative way C lets you manipulate arrays, pointers and
  27.       addresses must somehow assume, that they are stored contigious.
  28.   3)  It is most efficient that way (simpler address calculations).
  29.  
  30. But to be absolutely certain you will need to check the real sources:
  31. K&R and the ANSI specifications.
  32.  
  33.                                                           Arne
  34.  
  35. Arne Vajhxj                             local DECNET:  KO::ARNE
  36. Computer Department                     PSI:           PSI%23831001304030::ARNE
  37. Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK
  38.  
  39.