From: j DOT aldrich6 AT genie DOT com Message-Id: <199604040625.AA102929134@relay1.geis.com> Date: Thu, 4 Apr 96 05:57:00 UTC 0000 To: calvid AT rpi DOT edu Cc: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Subject: Re:Why doesn't this code work? Reply to message 8964006 from CALVID AT RPI DOT ED on 04/01/96 4:59PM > for(i=0; i<50; i++) > for(j=0; j<50; j++) > array1[i][j] = 0; > > array2[0] = 1; > array2[1] = 2; > cout << array2[(array1[i][j])] << endl; At the end of your for loops, i and j are each 50. This is out of the bounds of array1, which is subscripted [0..49][0..49]. Remember that array subscripts begin with zero! As a result, the value the program finds at array1[50][50] is a random piece of garbage in your memory somewhere, which will almost certainly cause unexpected results when used as a subscript of array2! The reason DJGPP gives you SIGSEGV is that it is much more particular about what areas of memory you access than is Linux. I you really want to initialize the array to zero on startup, why not just declare it static? John