From: gah AT jet DOT es (Grzegorz Adam Hankiewicz) Newsgroups: comp.os.msdos.djgpp Subject: Re: Problem Accessing Allegro Sprite Struct Members Date: Thu, 02 Jul 1998 17:20:54 GMT Organization: Gogosoftware Lines: 24 Message-ID: <359bc0c9.21926184@news.jet.es> References: <6nga3s$kqf$1 AT news2 DOT saix DOT net> NNTP-Posting-Host: info134.jet.es To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Thu, 2 Jul 1998 17:17:28 +0200, "Rylan" wrote: >I'm having a small prob accessing the RLE_SPRITE struct variables. >If I have a datafile variable "datafile" I access an item >datafile[The_Sprite].dat > >Now what I want to do is to access the "w" and "h" ints defined in >typedef struct RLE_SPRITE /* a RLE compressed sprite */ > >This would be done by referring to "datafile[The_Sprite].w" right? Nope. The datafile structure has only the members dat, type and two others. You have to extract the member from the dat pointer. The trick is to cast the pointer to access it's members, like this: w = ( (RLE_SPRITE *) datafile[The_Sprite].dat) -> w; Notice where are the brackets, and why, and you will see the point of casting. Since .dat is a void pointer, the compiler doesn't know what you want, and gives errors. - Grzegorz Adam Hankiewicz - gah AT jet DOT es - http://web.jet.es/gregorio/ - Gogosoftware - http://welcome.to/gogosoftware/