From: mike4148 AT aol DOT com (Mike4148) Newsgroups: comp.os.msdos.djgpp Subject: Arrays and Alignment Date: 24 Aug 1997 20:12:28 GMT Lines: 28 Message-ID: <19970824201201.QAA12844@ladder01.news.aol.com> NNTP-Posting-Host: ladder01.news.aol.com Organization: AOL http://www.aol.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I've had a recurring problem with just about every type of program imaginable (from simple test progs, to games with Allegro, to file manipulation utilites). Sometimes, when I create an array and index the last element, I get a SIGSEGV and the program terminates. Here is a little bit of pointless example code to illustrate the situation : int lots_of_ints[4]; lots_of_ints[4] = 1; Then the error occurs. It happens about 50% of the time, and with every type of variable imaginable. I was thinking it might be some sort of alignment thing (a la arrays in which the final element is accessed need to be of multiples of 2, 8, 16, etc.). Any suggestions? And then my second array-related question. I've never initialized arrays the conventional way. From BTC++ 3.0 to DJGPP I've always been used to initializing them in for loops or just not initializing them at all. Anyway, when I tried to initialize an array the normal way, it would start at element 1 and end at the last element. Here is an example : int lots_of_other_ints[4] = {0, 1, 2, 3, 4}; This snippet of code would get an error such as "array subscript out of bounds" (I'm not sure exactly what it was, this is the jist of it). I'm sure that no other part of my code is the problem. Any suggestions? Thanks in advance. mike4148 AT aol DOT com