Mail Archives: djgpp/1998/03/27/22:15:44
On Fri, 27 Mar 1998 23:42:32 GMT in comp.os.msdos.djgpp Lee
<jag*NOSPAM*@pangea.ca> wrote:
: In one of my menus, I need to pass more than one item of data thru the
: dp pointer, so I tried to declare a struct like so:
: struct moredata {
: int data1, data2;
: };
: mymenu[0].dp = &moredata; //assuming I declared mymenu as a MENU type
: earlier
: However, I can't access the fields within the moredata struct from the
: function called by my menu...it says something along the lines of data1
: not being a structure or union. Thanks for any help
Your syntax is a bit wrong. You need to put:
struct moredata the_data;
...
mymenu[0].dp = &the_data;
and to access the data, you need to cast the dp field to type "struct
moredata *" before dereferencing. Something like:
struct moredata *ptr = the_menu.dp; /* I forget how Allegro does this */
then use ptr->data1 and ptr->data2. I can't remember offhand how
Allegro tells you the value of `dp', but you should get the idea.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
[sb91sa93sclaPlbPlcPlbP]sb91sa93sclaPlbPlcPlbP
- Raw text -