delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/02/02:18:26

From: Chris Frolik <frolikcc AT indy DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ...
Date: Wed, 30 Jul 1997 03:03:52 -0500
Organization: IndyNet - Indys Internet Gateway (info AT indy DOT net)
Lines: 31
Message-ID: <33DEF568.5475@indy.net>
References: <970721172104_818627977 AT emout11 DOT mail DOT aol DOT com> <33e1c2cf DOT 7983444 AT news DOT netvision DOT net DOT il>
NNTP-Posting-Host: ip91-131.ts.indy.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ohad Somjen wrote:
> 
> On Mon, 21 Jul 1997 21:21:24 GMT, NoHero69 AT aol DOT com wrote:
> 
> >One quick question.  If I have a pointer that points a function, what is the
> >syntax of calling the procedure via the pointer?  Is it a simple CALL
> ><whatever> in ASM, and is there a way to do it outside the bounds of ASM?
> 
> if you define the following:
> void (*f_ptr)(char*);           //pointer to function that returns
>                                 //void and gets char*
> then in order to use it:
> f_ptr=&some_char_function;
> (*f_ptr)("bla bla bla);

I don't believe you need the '&' operator here, or the '*' operator with
the function call.  For example, if I have a function and a function
pointer:

void a_funtion(char *c);  /* function prototype */
void (*f_ptr)(char *);    /* function pointer */

I can use the function pointer to call the function by:

f_ptr = a_function;
f_ptr("bla bla bla");

Please correct me if I am mistaken.

-Chris
frolikcc AT indy DOT net

- Raw text -


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