Mail Archives: djgpp/1998/05/24/20:30:28
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Pointers to Functions, some help please?
|
Date: | Sun, 24 May 1998 16:54:06 -0700
|
Organization: | Alcyone Systems
|
Lines: | 35
|
Message-ID: | <3568B31E.4DC93551@alcyone.com>
|
References: | <35652BB5 DOT 337B AT linetap DOT com>
|
NNTP-Posting-Host: | charmaine.alcyone.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
nebo wrote:
> How does one initialize and access an array of pointers to
> functions( assuming this is even possible ), under DJGPP.
> Until now, I've had the need to only use a single pointer.
> If anyone knows, I'd appreciate the help.
Same as you'd for a single function pointer:
int f(void); /* The function you want to point to */
int (*pf)(void) = f; /* The function pointer */
(*pf)(); /* Call the function through the function pointer */
So:
int f(void), g(void), h(void); /* The three functions */
int (*apf[3])(void) = { f, g, h };
int i;
for (i = 0; i < 3; i++)
(*apf[i])(); /* Call each in a row */
Note that this is a general C question, and is not specific to DJGPP.
--
Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
Alcyone Systems / http://www.alcyone.com/max/
San Jose, California, United States / icbm:+37.20.07/-121.53.38
\
"Since when can wounded eyes see / If we weren't who we were"
/ Joi
- Raw text -