call a function inside argument of another function c code example
Example 1: call a function inside argument of another function c
int main (void) {
Repeat(SayHello,4);
Repeat(SayGoodbye,2);
}
void Repeat(void (*fct)(int), int i) {
for (int j=0, j
Example 2: passing a function as an argument in c
void func ( void (*f)(int) ) {
for ( int ctr = 0 ; ctr < 5 ; ctr++ ) {
(*f)(ctr);
}
}
Example 3: passing a function as an argument in c
void func ( void (*f)(int) );