[comp.sys.mac.programmer] For Loops, something crazy!

kevin@crash.cts.com (Kevin Hill) (01/15/91)

	for(j = -1;j < 2;j++)
	{
		
		for(k = -1;k < 2;k++)
		{
			printf("%3d %3d\t",j,k);
			i++;
			surround[i] = track[gx+k][gy+j];
			if ( (gx+k) < 0)
				surround[i] = -1;
			if ( (gx+k) > GXMAX)
				surround[i] = -1;
			if ( (gy-j) < 0)
				surround[i] = -1;
			if ( (gy-j) > GYMAX)
				surround[i] = -1;
		}
		
	}


  This programmer is very frustrated.  This loop, programmed in THINK C
dos not seem to work.  It loops a couple of extra times, and I cannot figure
out why.
  If is supposed to loop three times for a total of i = 9.
[B[D[B[A[B.