www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/24/20:50:08.1

Sender: nate AT cartsys DOT com
Message-ID: <36D49611.BF29AF33@cartsys.com>
Date: Wed, 24 Feb 1999 16:15:13 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.1 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Help
References: <36D162CB DOT E5B730A6 AT game-master DOT com> <36D2009E DOT E256EFBD AT cartsys DOT com> <36D46320 DOT 114420E4 AT game-master DOT com>
Reply-To: djgpp AT delorie DOT com

Kevin Lang/Ultima wrote:
> 
> Nate Eldredge wrote:
>
> > iso_map->tile_map[((iy<<(iso_map->ysize))+ix)].attributes
> >
> > Actually, it's quite simple.  You can see that TILE.attributes is indeed
> > an `int', so the compiler is quite justified.
> >
> > I assume what you want to do is read the contents of the `attributes'
> > member from the packfile.  `pack_fread' wants its first arg to be a
> > pointer to the buffer into which to read.  Therefore, all you need to do
> > is take the address of this horrible expression (with the `&' operator)
> > and pass that.
> 
> Yes I sortof figured this out a little while after :-)But  I don't get why I should use the .
> operator instead of ->
> 
> You are supposed to use -> when you are using a pointer to a struct right?
> But tile_map is also a pointer to a struct, so how come the compiler wants me to put a . instead
> of ->

`tile_map' is a pointer, correct.  However, `tile_map[nnn]' is not; it
is one of the elements of `tile_map', which is an array.  Each of these
elements *is* a struct and not a pointer.

It may help to know that `p[x]' is equivalent to `*(p+x)'.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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