2

Please consider the following code

#include<stdio.h>
int fun(); /* function prototype */

int main()
{
    int (*p)() = fun;
    (*p)();  
    return 0;
}
int fun()
{
    printf("IndiaBix.com\n");
    return 0;
}

What is int(*p)() here?Is it a function,variable or what?

3
  • 2
    p is a function pointer points to a funtion that returns a value of type int. Commented Sep 15, 2013 at 8:12
  • 8
    When in doubt, just use cdecl.org: cdecl.ridiculousfish.com/?q=int%28%2Ap%29%28%29. Commented Sep 15, 2013 at 8:14
  • Some info on function pointers: newty.de/fpt/index.html Commented Sep 15, 2013 at 8:20

3 Answers 3

6

Flow spiral rule :

                 +------+
                 |      |
                 |  +-+ |
                 |  ^ | |            
             int ( *p ) ()
               ^ |    | |
               | +----+ |
               +--------+

               Identifier p
                 is a pointer to..
                 is a pointer to a function  
                 is a pointer to a function returning int
Sign up to request clarification or add additional context in comments.

Comments

1

p is a pointer. the (*p)() means he is a pointer to a function . int (*p)() also means the function it points to return integer.

Comments

0

int(*p)() - p is a pointer to function which receives nothing and returns an int.

p is therefore a variable ofc.

1 Comment

Actually in C it can receive any number of parameters, since it is not declared as (void).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.