Advertisement
Guest User

callback.c

a guest
Sep 19th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void foo(int);
  4. void testCallback(int, void (*)(int));
  5.  
  6. int main(int argc, char **argv){
  7.  
  8.   testCallback(1000000, &foo);
  9.   printf("[Main function]: I'm main function!\n");
  10.     testCallback(100000, &foo);
  11.    
  12.   return(0);
  13. }
  14.  
  15. void foo(int num){
  16.   printf("[foo function]: I'm callback!, Parameters[ num=%d ]\n",num);
  17. }
  18.  
  19. void testCallback(int num, void (*callback)(int)){
  20.    int i;
  21.    
  22.    for(i=0; i < num; i++);
  23.  
  24.   return(callback(num));
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement