Created
October 18, 2013 08:45
-
-
Save arafatkamaal/7038534 to your computer and use it in GitHub Desktop.
Function Pointers in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int CallBackFunction(int i){ | |
printf("This is the call back function %d\n", i); | |
} | |
int Operations(int (*func)(int)){ | |
printf("\nRecieving function pointer\n"); | |
(*func)(3); | |
printf("\nPassing function pointer\n"); | |
AnotherOperation(*func); | |
AnotherOperation(func); | |
} | |
int AnotherOperation(int (*func)(int)){ | |
printf("\nRecieved function pointer again"); | |
(*func)(4); | |
} | |
int main(){ | |
printf("\nPassing params\n"); | |
int (*func)(int); | |
func = &CallBackFunction; | |
func(2); | |
Operations(func); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment