Thread: Pointer to Functions

  1. #1
    Registered User
    Join Date
    Dec 2010

    Pointer to Functions

    Hi everyone;

    I make a try to use a pointer to function. However I get a garbage value. Could you please check my code?

    #include <stdio.h>
    int main(void){
    int (*p)(int,int);
    int f1(int x, int y);
    int a=5;
    int b=3;
    int c=(*p)(a,b);
    return 0;
    int f1(int x, int y){
    return ((x+y)*(x+y));
    Edit: I see when I use printf("%d",c); instead of printf("%d",*p); I get the correct result. I wish I was able to delete the post.
    Last edited by GokhanK; 08-15-2013 at 11:51 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 02-02-2013, 09:33 PM
  2. Need help with beginner pointer functions.
    By Mo777 in forum C Programming
    Replies: 9
    Last Post: 02-17-2011, 03:30 PM
  3. Pointer-to-member functions
    By EvilGuru in forum C++ Programming
    Replies: 21
    Last Post: 01-12-2008, 04:50 AM
  4. Pointer to functions
    By seizmic in forum C Programming
    Replies: 13
    Last Post: 09-08-2005, 12:56 PM
  5. pointer functions
    By kurz7 in forum C Programming
    Replies: 2
    Last Post: 06-04-2003, 07:56 AM