I am working on porting a program from C to Java. I did not write the original code, but there are several instances where the original programmer references [-1] as an array index. It is ALWAYS in a multi-dimensional array and it is ONLY in the first field for the array. For example:
Obviously, Java gives ArrayIndex errors, but apparently C permits it.Code:for (i=0; i < numRows; i++) for (j=0; j < numCols; j++) { za[i][j] = mapConf[-1][i][j]; h[i][j] = za[i][j]; if (h[i][j] < sealevArray[0]) h[i][j] = sealevArray[0]; qx[i][j] = 0.; qy[i][j] = 0.; } }
Can anyone tell me how to translate that? Does it really mean the first index in the array or is there something exotic happening with the pointers?
This application does work in the original C. It was originally developed with the C compiler shipped with SGI's in case that makes a difference.