C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - General Questions (Q.No. 9)
What do the following declaration signify?
int *f();
f is a pointer variable of function type.
f is a function returning pointer to an int.
f is a function pointer.
f is a simple declaration of pointer variable.
Answer: Option
No answer description is available. Let's discuss.
6 comments Page 1 of 1.

A.Srikanth said:   6 years ago
No, it is wrong @Natwar.

Please correct in return statement.t return(x) instead of return(*x) and in main() function printf statement printf("*b=%d\n",*b) instead of printf("*b=%d\ n",*b);.

Natwar said:   8 years ago

int *f(void)
int *x;
int a=10;
x = &a;
printf("*x = %d\n",*x);
return (*x);
int main()
int *b;
b = f();
printf("*b = %d\n",b);

return 0;

Jarvis said:   9 years ago
OK its cool declaration but can you give an example program so that it'll be more clear?

Athul m das said:   9 years ago
Int *f() is an int pointer but when enclosed in parenthesis int (*f)() it becomes a pointer to a function returning int.

Prajakta said:   10 years ago
Trick: here () indicates function(method in java) and * sign is given before () so f is function returning pointer and return type is int so, answer B is correct.

Sathish said:   1 decade ago
if we put *f in parenthesis it is pointer to function here parenthesis have greater precedence than astrek operator.

Post your comments here:

Your comments will be displayed after verification.