Pointers to Functions
Dave Bloom
dave at andromeda.UUCP
Fri Jan 10 04:46:33 AEST 1986
<>
Here's a good(?) question. Lets say I have this:
main()
{
int a(), b(); /* defined somewhere else */
int (*c)(); /* a pointer to a function returning int (K&R pg141) */
.
.
.
c = b;
(*c)(some arguments);
}
Our compiler claims c is an "illegal function", yet the following it
permits:
main()
{
int a(), b();
a(b);
}
a(x)
int (*x)();
{
(*x)(some arguments);
}
Looks like I'm missing something. Can anyone out the lend me a hand???
What is it that's wrong in example one? How can I declare a generic pointer
to an int-function, set it equal to the address of a valid int function,
and use it instead of the function????
Thanx.
--
-------------------------------------------------------------------------------
allegra\ Dave Bloom
harvard \ pyramid\
seismo \ pyrnj >!andromeda!dave HOME: (201) 868-1764
ut-sally >!topaz/ WORK: (201) 648-5083
sri-iu /
ihnp4!packard / "You're never alone with a schizophrenic...."
More information about the Comp.lang.c
mailing list