Practice mode C Language

Which declaration makes pf a pointer to a function that takes two int arguments and returns int?

Correct answer D. int (*pf)(int, int);

Explanation

The parentheses around *pf make pf a pointer first, and that pointer points to a function taking (int, int) and returning int. Without them, int *pf(int, int); declares a function named pf that returns a pointer to int, which is a different thing entirely. Function pointers are used for callbacks, such as the comparison function passed to qsort.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.