D
Daniel Rudy
Hello,
How does one call a pointer? Basically, what I would like to do is
have an array of pointers so that a value of a variable in a struct will
act as an index to the array, which contains the addresses of routines.
How does one do this in C? Can it be done? I'm still new to C, so
some of the code below will not be valid...Like the pointer type.
#include <stdio.h>
pointer array[3];
int x;
int routine1()
{
printf("This is routine 1\n");
return(0);
}
int routine2()
{
printf("This is routine 2\n");
return(0);
}
int routine3()
{
printf("This is routine 3\n");
return(0);
}
int main()
{
array[0] = addressof(routine1);
array[1] = addressof(routine2);
array[2] = addressof(routine3);
x = 2;
call(array[x]);
return(0);
}
How does one call a pointer? Basically, what I would like to do is
have an array of pointers so that a value of a variable in a struct will
act as an index to the array, which contains the addresses of routines.
How does one do this in C? Can it be done? I'm still new to C, so
some of the code below will not be valid...Like the pointer type.
#include <stdio.h>
pointer array[3];
int x;
int routine1()
{
printf("This is routine 1\n");
return(0);
}
int routine2()
{
printf("This is routine 2\n");
return(0);
}
int routine3()
{
printf("This is routine 3\n");
return(0);
}
int main()
{
array[0] = addressof(routine1);
array[1] = addressof(routine2);
array[2] = addressof(routine3);
x = 2;
call(array[x]);
return(0);
}