A variable must hold a pointer to a function taking an int and returning int. Which declaration is right, and how does it compare with the alternative?
Aint (*fp)(int); which means exactly the same thing as int *fp(int) under the C declarator precedence rules
Bint fp(*)(int); which places the pointer inside the parameter list rather than on the name
Cint (*fp)(int); which declares a function pointer, unlike int *fp(int) which declares a functionCorrect answer
Dint *fp(int); which declares a function pointer, while int (*fp)(int) declares a function
Correct answer
C. int (*fp)(int); which declares a function pointer, unlike int *fp(int) which declares a function
Declarator precedence binds the parentheses around *fp first, so int (*fp)(int) is a pointer to function, while int *fp(int) declares a function returning int*. Reading a declaration inside out from the identifier resolves such puzzles quickly. The same rule explains why an array of function pointers is written int (*tab[3])(int).