I looked, but could not find a direct link to this question. I'm new to function pointers (and C), so I don't know all the tricks that can still be done :)
I really got the function:
void select_comparator(My_Struct *structure, int (*comp)(int x, int y)) {
...
... where it My_Structhas a prototype:
typedef struct my_struct {
int (*comp)(int x, int y);
} My_Struct;
Change some small details. I just want to know if the following is the correct syntax:
void select_comparator(My_Struct *structure, int (*comp)(int x, int y)) {
structure->comp = comp;
}
It seems to be too easy, and I'm worried.
source
share