A question of stylecode!

Dave Decot decot at hpisod2.HP.COM
Fri Dec 15 12:15:45 AEST 1989


> 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



More information about the Comp.lang.c mailing list