home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16165 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.7 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
  2. From: torek@horse.ee.lbl.gov (Chris Torek)
  3. Newsgroups: comp.lang.c
  4. Subject: passing 2-dimensional arrays (was Someone help me with this)
  5. Date: 8 Nov 1992 09:41:58 GMT
  6. Organization: Lawrence Berkeley Laboratory, Berkeley
  7. Lines: 34
  8. Message-ID: <27295@dog.ee.lbl.gov>
  9. References: <1992Nov6.210507.2887@vela.acs.oakland.edu> <1992Nov6.235237.25636@sbcs.sunysb.edu>
  10. Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
  11. NNTP-Posting-Host: 128.3.112.15
  12.  
  13. (Note: Please use descriptive subject lines.  `Help me with this' is
  14. generally not very descriptive.)
  15.  
  16. In article <1992Nov6.235237.25636@sbcs.sunysb.edu>
  17. rhorn@csws17.ic.sunysb.edu (Robert Horn) points out that declarations
  18. of the form
  19.  
  20.     t1 f(t2 v[][])
  21.  
  22. (where t1 and t2 are types, f is a function name, and v is a variable
  23. name) are illegal in C.  Further correct information can be found in
  24. the comp.lang.c FAQ.
  25.  
  26. >... your example: char timetab[33][31] specifies an array from 0
  27. >    to 30 of arrays 0 to 32 of characters.
  28.  
  29. This is backwards: the definition[%]
  30.  
  31.     char timetab[33][31];
  32.  
  33. declares timetab as an object of type `array 33 of array 31 of char'.
  34. Each of the first `array's (each timetab[i] such that 0 <= i < 33) is
  35. itself an <object, array 31 of char> and thus for each one, you can
  36. write timetab[i][j], where j >= 0 and j < 31.
  37. -----
  38. % I say `definition' here to avoid the issue of formal parameter
  39.   declarations (which are not definitions, and which act funny when
  40.   told that a formal parameter has an array type).
  41. -----
  42.  
  43. Again, see the FAQ for more detail.
  44. -- 
  45. In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
  46. Berkeley, CA        Domain:    torek@ee.lbl.gov
  47.