Although C does not do array subscript checking , some compilers like mine
sun workshop c/c++ 4.2] say "cannot access memory location xyz..." when
trying to access memory beyond the [subscript - 1 ] element in an array.
anubhav
-----Original Message-----
From: Darius Blaszijk <[EMAIL PROTECTED]>
To: linux c programming <[EMAIL PROTECTED]>
Date: Saturday, April 10, 1999 6:13 AM
Subject: array filling problem
>I keep getting strange results with the following program:
>
>---------------------------------------------------------------------------
---------
>
>#include<stdio.h>
>int main ()
>{ const dim = 5;
> float a[dim-1][dim-1];
> int i, j;
>
> /* reset array */
> for (i=0; i<=dim-1; i++)
> for (j=0; j<=dim-1; j++)
> a[i][j]=0;
>
> /* fill in some data-points */
> a[0][0]=1; a[0][4]=4; a[4][0]=4; a[4][4]=8;
>
> /* print array */;
> for (i=0; i<=dim-1; i++)
> { for (j=0; j<=dim-1; j++)
> { printf("[%d][%d]=%1.1f ",i,j,a[i][j]);
> }
> printf("\n"); }
>
> return 0; }
>---------------------------------------------------------------------------
---------
>
>When the array position [0][4] is filled, the position [1][0] also gets
>filled. This same
>problem occurs when filling the [4][0] position. In this case the
>previous data position [3][4] gets filled
>
>Tanks in advance, Darius Blaszijk