A question of style

decot at hpisod2.hp.com decot at hpisod2.hp.com
Thu Dec 21 16:03:00 AEST 1989


From: decot at 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



More information about the Comp.lang.c mailing list