M
Mackan
Hi!
I'm trying to declare a structure that will be including pointers to
functions. These structures in turn will be pointed to in an array and
depending on a index value that specific function in the structure pointed
to by the index will be called with various data.
Say i have a couple of functions:
int func1(int , int);
int func2(int, int);
Then i have a structure:
typedef struct {
int someval;
/* Below is where i'm not sure how to declare,
* here is where one of the functions above will be inserted */
int *somefunction();
} mystruct;
Then i initialize the array wich should point to structures:
mystruct myarray[] = {{10,func1()},{20,func2()},{30,func1()}};
Now when executing the line below and say array_index below is 0 it will
call function func1():
myarray[array_index]->somefunction(value1, value2);
Anybody understand what i mean? I just don't know how to declare the
function in the structure "mystruct" above.
Mats
I'm trying to declare a structure that will be including pointers to
functions. These structures in turn will be pointed to in an array and
depending on a index value that specific function in the structure pointed
to by the index will be called with various data.
Say i have a couple of functions:
int func1(int , int);
int func2(int, int);
Then i have a structure:
typedef struct {
int someval;
/* Below is where i'm not sure how to declare,
* here is where one of the functions above will be inserted */
int *somefunction();
} mystruct;
Then i initialize the array wich should point to structures:
mystruct myarray[] = {{10,func1()},{20,func2()},{30,func1()}};
Now when executing the line below and say array_index below is 0 it will
call function func1():
myarray[array_index]->somefunction(value1, value2);
Anybody understand what i mean? I just don't know how to declare the
function in the structure "mystruct" above.
Mats