home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16722 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.7 KB  |  47 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!stanford.edu!rock!taco!jlnance
  3. From: jlnance@eos.ncsu.edu (JAMES LEWIS NANCE)
  4. Subject: Re: What is meant by: double A[n,m]?
  5. Message-ID: <1992Nov18.133002.25546@ncsu.edu>
  6. Originator: jlnance@kelley.ece.ncsu.edu
  7. Lines: 33
  8. Sender: news@ncsu.edu (USENET News System)
  9. Reply-To: jlnance@eos.ncsu.edu (JAMES LEWIS NANCE)
  10. Organization: North Carolina State University, Project Eos
  11. References:  <TORSTEIN.92Nov18125146@itekiris.kjemi.unit.no>
  12. Date: Wed, 18 Nov 1992 13:30:02 GMT
  13.  
  14.  
  15. In article <TORSTEIN.92Nov18125146@itekiris.kjemi.unit.no>, torstein@itekiris.kjemi.unit.no (torstein hansen) writes:
  16. |> 
  17. |> As a newcomer to C, previously programming in Pascal, I used the
  18. |> following declaration in one of my programs:
  19. |> 
  20. |> double A[n,m];
  21. |> 
  22. |> I assumed (erronously) that this would give a n by m matrix. But
  23. |> obviously, it didn't.  But the compiler never gave any errors or
  24. |> warnings, and using 
  25. |> 
  26. |>   A[rownumber,colnumber]=some_value;
  27. |>  
  28. |> was also accepted by the compiler.  I'm not asking for the correct 
  29. |> way to define an array, I found that out quickly, but what is meant 
  30. |> by A[n,m]?  It seems like the compiler just ignores the n and makes 
  31. |> it A[m].  This is also the case when assigning values to the array.
  32.  
  33.  
  34. |> Can somebody enlighten me in this matter?  I couldn't find anything
  35. |> about it in any of the C books I have.  If double A[n,m] is illegal,
  36. |> shouldn't I get a warning at least?
  37. |> 
  38. |> Has it something to do with the comma operator, discarding the first
  39. |> value inside the braces?
  40.  
  41. I have made this mistake also.  I believe that it does have to do with the
  42. comma operator, which would make the expressions 2,2 == 2.  The correct way
  43. to define your array would be a[n][m].
  44.  
  45.  
  46. Jim Nance
  47.