[comp.lang.c] A question of style

decot@hpisod2.hp.com@canremote.uucp (decot@hpisod2.HP.COM) (12/21/89)

From: decot@hpisod2.HP.COM (Dave Decot)
Subj: Re: A question of stylecode!
Orga: Hewlett Packard, Cupertino

> I always thought that an interesting use for the comma was in a for
> loop when one wanted, say, to create the identity matrix:

I agree completely.  However the following code:

>       float   array[SIZE][SIZE];
>       int     i,j;
> 
>       /* initialize the whole thing to zero, then to this: */
>       for(i=0,j=0; i<SIZE; i++, j++)
>               array[i][j] = 0;

creates the following matrix:

      0     garbage garbage garbage ... garbage
    garbage    0    garbage garbage ... garbage
    garbage garbage    0    garbage ... garbage
      .        .       .       .    ...    .
      :        :       :       :    :::    .
    garbage garbage garbage garbage ...    0

...which is not precisely what I wanted.

Dave Decot

---
 * Via MaSNet/HST96/HST144/V32 - UN C Language
 * Via Usenet Newsgroup comp.lang.c