home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!ugle.unit.no!ugle.unit.no!torstein
- From: torstein@itekiris.kjemi.unit.no (torstein hansen)
- Subject: What is meant by: double A[n,m]?
- Message-ID: <TORSTEIN.92Nov18125146@itekiris.kjemi.unit.no>
- Sender: news@ugle.unit.no (NetNews Administrator)
- Organization: Dept. of Chem.Eng, Norwegian Inst. of Tech
- Date: 18 Nov 92 12:51:46
- Lines: 43
-
- 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.
-
- That is:
- double A[2,2];
- gave same result as
- double A[2];
-
- A[0,1] = some_value;
- gave same result as
- A[1,1] = some_value;
- and
- A[1] = some_value;
-
- 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?
-
- By the way, the compiler I used was Turbo C++ ver. 3.1, just in case
- this behaviour isn't standard.
-
-
- Torstein Hansen
- torstein@itekiris.kjemi.unit.no
- --
- Torstein Hansen
- torstein@itekiris.kjemi.unit.no
-