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