From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: I'm going slightly mad!! Date: Thu, 26 Feb 1998 10:46:09 +0100 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 48 Message-ID: <34F539E1.3347E282@LSTM.Ruhr-UNI-Bochum.De> References: <34F50789 DOT 3AB6 AT stud DOT warande DOT ruu DOT nl> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Elliott Oti wrote: > > My guess would be you're writing to invalid pointers somewhere. > > I have made some dumb mistakes in my time, and I hope you will forgive > the liberty of > sharing one with you. Who knows, it may help. I call it: > > "Reading integer offsets from files and forgetting that arrays in C > begin from 0." > > and it goes like this: > > I read an array of N points from a 3d object file. > Then I read a triangle in. It is composed of points 15, 16, and 17 of my > array. > At least, that's what the file says. So I say: > triangle T = { Array[15], Array[16], Array[17] } [... rest of very familiar bug removed] Two solutions: 1.) Start numbering your points with 0, that's what I do in my FEM/FVM code when working on unstructured grids. 2.) Do something like Array = malloc(n*sizeof(*Array)); --Array; ... free(++Array); Then you have Array[1]..Arrray[n] as valid subscripts. Whatever you do, do it consistently. -- Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************