delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/27/22:15:44

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help : Allegro Menu *dp
Date: 28 Mar 1998 01:53:08 GMT
Organization: Oxford University, England
Lines: 35
Message-ID: <6fhl64$g5i$1@news.ox.ac.uk>
References: <351C39E1 DOT B5F383B AT pangea DOT ca>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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