home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!think.com!rpi!ghost.dsi.unimi.it!itnsg1.cineca.it!ditolla
- From: ditolla@itnsg1.cineca.it (Francesco Di Tolla)
- Subject: Re: What is meant by: double A[n,m]?
- Message-ID: <1992Nov18.125904.25326@itnsg1.cineca.it>
- Organization: Laboratorio di Fisica Computazionale, INFM. Trento Italia
- References: <TORSTEIN.92Nov18125146@itekiris.kjemi.unit.no>
- Date: Wed, 18 Nov 1992 12:59:04 GMT
- Lines: 45
-
- 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.
-
- In c 'n,m' is an expression which has the value of m because expressions
- separated by commas are evluated from left to right and only the last
- value is kept:
-
- exp1, exp2, ....,expN;
-
- this evaluets to expN.
- so
-
- a=(b=5,b+1);
-
- will assign 5 to b and 6 to the a in a way which is harder to understand than
-
- b = 5;
- a = b + 1;
-
- >Torstein Hansen
- >torstein@itekiris.kjemi.unit.no
-
-
- Bye
- Franz
- --
- --------------------------------------------------------------------------
- | Francesco D. Di Tolla | Intern. School for Advanced Studies |
- | Dip. di Fisica Univ. di Trento | SISSA/ISAS via Beirut, 2-4 |
- | I-38050 Povo (TN) | I-34013 Trieste |
-