🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52670

Re: function call as pointer

#52670
From: Martin Gaeckler
Date: Sun, 07 Jun 1992 21:53
30 lines
1108 bytes
HI RALF,

what do you think about that:

double H( int x )
{
     // do something
}

double V( int x, double (*f)(int) )
                          ^
                          * This is a pointer to a function getting an inte-
                          * ger and returning a double
{

     return f( x );
}

int main( void )
{
     printf( "The result is %f\n", V( 10, H );
                                          ^
                                          * This is the adress of function H

     return 0;
}

hope this helps

Martin
Technical Details
Message-ID: <A17992@M.maus.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!uniol!hb.maus.de!m.maus.de!Martin_Gaeckler
References: <A46903@HB.maus.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,d01dfcf765dbe89a,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-06-08 19:20:17 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!Germany.EU.net!uniol!hb.maus.de!m.maus.de!Martin_Gaeckler
From: Martin_Gaeckler@m.maus.de (Martin Gaeckler)
Newsgroups: gnu.gcc.help
Subject: Re: function call as pointer
Message-ID: <A17992@M.maus.de>
Date: Sun, 07 Jun 92 21:53:00 GMT
References: <A46903@HB.maus.de>
Organization: MausNet
Lines: 30
X-Gateway: MausGate/News 1.07