pointers to functions?
Charles L Savage
savage at boulder.Colorado.EDU
Thu Feb 23 20:08:02 AEST 1989
I am having major problems getting a pointer to a fuction to execute. Somehow the calling fuction, when is should call the passed function it is just dropping out of its own function as if it had executed a return statement, instead of the fuction call. Can somebody point me in the right direction? Here is the code as close and as short as I could make it:
void copy_func(); /* data dependant copy function */
main()
{
...
(void) g(copy_func);
...
}
char * g(cpy_ptr)
void (*cpy_ptr)();
{
...
(void)printf("before call\n");
(*cpy_ptr)(data1, data2); /* data1 and data2 are pointers to structures of type DATUM */
...
}
void cpy_func(t,f)
DATUM *t, *f; /* copy (struct)DATUM 'f' to (struct)DATUM 't' */
{
(void)printf("Here I am in cpy_func\n");
*t = *f;
...
}
The program executes g() through "before call", then drops out just after printing "before call" just as if it had hit a return statement.
^
//
//
_ #
/@\ #------------------------------------------------------.
{@@@}%%%%%%%%%%%%#=======================================================>
\@/ #------------------------------------------------------'
#
\\ Savage%alta at boulder.colorado.EDU
\\
v
More information about the Comp.lang.c
mailing list