#include #include void say1(void) { printf("hello, world!\n"); } void say2(void) { printf("hello bro!\n"); } /* quite silly function, it is better to return an int and modify a parameter */ void (*swap_say( void (*current_say)(void) )) (void) { if (!current_say) return NULL; void (*ret)(void) = NULL; if (current_say == &say1) ret = say2; else ret = say1; return ret; } int main(int argc, char **argv) { void (*say_fptr)(void) = say1; say_fptr(); /* now modfiy the above func ptr */ say_fptr = swap_say(say_fptr); say_fptr(); return 0; }