"jobo" <jo*****@gmail. comwrites:
If I have the function:
int f(int (*h)(int)) {
return (*h)(13);
}
What exactly does (int (*h)(int)) do? So it's taking a pointer but
what's with the two ints? Thanks.
f is a function that returns a result of type int. It has a single
parameter, "h", of type int (*)(int). In other words, h is a pointer
to a function; that function has a single parameter of type int, and
returns a result of type int.
There's a program called "cdecl" that's often helpful for this kind of
thing (though it doesn't like the parameter name):
% cdecl
Type `help' or `?' for help
cdeclexplain int f(int (*h)(int))
syntax error
cdeclexplain int f(int (*)(int))
declare f as function (pointer to function (int) returning int) returning int
cdecl>
I got it from
<http://www.ibiblio.org/pub/Linux/devel/lang/c/cdecl-2.5.tar.gz>
--
Keith Thompson (The_Other_Keit h)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.