pointers to functions
Tom Armistead
toma at killer.UUCP
Sat Jun 21 06:41:10 AEST 1986
The delima - Is it possible to cast a 'pointer to' a function?
What I have is a char * that holds the address of a function.
int foo();
char *addr = foo;
Would it be possible to call the function foo() via the variable addr?
Secondly is it possible to have an array of type 'pointer to' function.
i.e.
int (*function)()[SIZE];
something like the above, I was able to achieve this using this:
struct fct {
int (*func)();
} f_array[SIZE];
function()
{
int x;
printf("offset: ");
scanf("%d",&x);
(*f_array[x].func)();
}
Is there another way???
Something to think about...
Thanx in advance for **ANY** help,
- Tom
---
UUCP:
ihnp4!cuae2!tuxa!we53!sw013b! \
\dj3b1!killer!toma
/
drillsys!infoswx!convex!/
Tom Armistead
More information about the Comp.lang.c
mailing list