Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void A(int a)
- {
- printf("I am in function A and here's a: %dn", a);
- }
- // callback function
- void B(void (*ptr)(int b) )
- {
- // int b = 5;
- int b;
- printf("I am in function B and b = %dn", b);
- (*ptr) (b); // callback to A
- }
- int main()
- {
- int c = 6;
- void (*ptr)(int c) = &A;
- // calling function B and passing
- // address of the function A as argument
- B(ptr);
- return 0;
- }
Add Comment
Please, Sign In to add comment