www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/30/16:45:39

From: Spiritseeker <spiritseeker AT geocities DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How come there are five "4" in the array, when i only set four!?
Date: Wed, 31 Dec 1997 05:18:08 +0100
Organization: A customer of Tele2
Lines: 32
Message-ID: <34A9C780.4D0@geocities.com>
References: <34A8599C DOT 45D AT geocities DOT com> <5GefBIAU2Rq0Iw3V AT sunholme DOT demon DOT co DOT uk>
NNTP-Posting-Host: mn8.swip.net
Mime-Version: 1.0
Cache-Post-Path: mn8!s-23470 AT dialup169-2-54 DOT swipnet DOT se
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> Inside the constructor...
> 
> > /* clear the array */
> > for(y=0;y<Y_SIZE;y++)
> >  for(x=0;x<X_SIZE;x++)
> >    *(tile_data + (y * Y_SIZE) + x) = 0;
> 
> Each line is X_SIZE in width... so why are you multipling the Y
> coordinate by the number of lines (Y_SIZE) rather than the width of each
> line? (X_SIZE) :-)

Oh.. OH..  OH... (font_size += 9.87654321) *OH* heh, man.. why is the
obvious always so !obvious. 8-)

> 
> for(y=0;y<Y_SIZE;y++) {
>         for(x=0;x<X_SIZE;x++) {
>                 printf("%d",*(tile_data+(y*X_SIZE)+x));
>         }//                              ^^^^^^^^ <--- note!
>         printf("\n");
> }

Okay, got it =)

> 
> As an alternative approach, which would leave out all that
<snip!>
> which has the advantage of being much easier to read!
> 

Thank you!,
/Jonas

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019