From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Bug in gcc 2.7.2? Date: Thu, 16 Apr 1998 23:20:00 +0200 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 37 Message-ID: <35367600.83A29F93@LSTM.Ruhr-UNI-Bochum.De> References: <35360BD4 DOT 5DB6C8C5 AT sis DOT co DOT at> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit CC: "Gerhard W. Gruber" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Gerhard W. Gruber wrote: > > I just encountered a strange thing. I was using a loop that process a buffer. > When the index is outside the buffersize the code should read the next block > from the file and continue. To do this I'm using the modulo operator but there > seems a bug with this. It's late and I might be completely wrong, but what the heck you want to do? I guess something like this: char elem(unsigned index){ static unsigned long oldblock; static int been_here = 0; static char buff[BUFLEN]; long block; block = index/BUFLEN; if(!been_here || block != oldblock){ been_here = 1; Read_Block( oldblock=block ); } return buff[ index % BUFLEN]; } 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 * *************************************************************