home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!portal!dfuller
- From: dfuller@portal.hq.videocart.com (Dave Fuller)
- Subject: Re: pointers to functions
- Message-ID: <BxBnoB.49o@portal.hq.videocart.com>
- Organization: VideOcart Inc.
- X-Newsreader: Tin 1.1 PL3
- References: <1992Nov6.234729.13866@koko.csustan.edu>
- Distribution: na
- Date: Sat, 7 Nov 1992 01:19:22 GMT
- Lines: 30
-
- pendell@deneb.csustan.edu (Brian Pendell) writes:
- : Greetings!
- :
- : As many of you already know, the declaration
- :
- : double (*pfun) ();
- :
- : declares pfun to be a pointer to a function which returns double.
- :
- : Now, how do I call the function using the pointer? That is, the next
- :
- : instruction should be:
- :
- : "Call the function pointed to by pfun with parameters A and B"
- :
- : function (A,B), in other words.
- :
- Brian,
- if A and B were ints, and we were worried about ANSI we would have to
- redeclare it as double (*pfun)(int , int );
-
- then to call it (assuming retval is a double and pfun is the address of
- the function) just do this :
-
- retval = (* pfun)(A, B);
-
-
- Dave Fuller
- dfuller@portal.hq.videocart.com
-
-