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

  1. Path: sparky!uunet!stanford.edu!rutgers!usc!news.service.uci.edu!unogate!mvb.saic.com!macro32
  2. From: MILLER@TGV.COM
  3. Newsgroups: vmsnet.internals
  4. Subject: Re:  C Language question
  5. Message-ID: <718580974.504412.MILLER@TGV.COM>
  6. Date: 8 Oct 92 21:49:34 GMT
  7. Organization: Macro32<==>Vmsnet.Internals Gateway
  8. Lines: 23
  9. X-Gateway-Source-Info: Mailing List
  10.  
  11.  
  12. >Question: in C, if one declares char a[I][J], is there anything in the
  13.  
  14. Remember:  a[i] really means *(a+i) using the rules for pointer addition.
  15. a[i] is a macro construct.
  16.  
  17. So a[i][j] really works out to *((char *)&*(a+i) + j), I think.
  18. So "a" has an "element size" if J characters in this context.
  19. If we declare "char *b = a;" then the following should work:
  20.  
  21.         a[i][b] == *((b+i*J) + j)
  22.  
  23. and
  24.  
  25.         &a[i][b] == ((b+i*J) + j)
  26.  
  27. In as much as linear array elements are contiguous, so are multi-
  28. dimentional array elements, since they are simply arrays of arrays.
  29.  
  30. Check K&R for details (see pointer arithmatic, and multinet-dimentional
  31. arrays).  I have no idea what ANSI has to say on the subject.
  32.  
  33. -bruce
  34.