Function Pointer (Function pointer Part I)

Here you can find a simple implementation of function pointers in C.

#include <stdio.h>

void myFunction() {
    puts("hello");
}

int main(int argc, char * argv[]) {
    /* pointer to void function with no parameters myFunction */
    void (*myFunctionPointer)() = myFunction;
    /* call original function */
    myFunction();
    /* call our new pointer function */
    myFunctionPointer();

    return 1;
}
  • Digg
  • del.icio.us
  • Facebook
  • Technorati
  • Twitthis
  • FriendFeed

POST A COMMENT

  • You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>