asked 199k views
3 votes
What does "int (fp)(int,char);" mean?

a) fp is a pointer to a function that takes an integer and a char* and returns an integer
b) fp is a function that takes an integer and a character as arguments and returns an integer
c) fp is a pointer to an integer and a character
d) fp is a pointer to a function that returns an integer and has undetermined parameters

asked
User Kwill
by
7.7k points

1 Answer

3 votes

Final answer:

The C/C++ declaration "int (fp)(int,char);" defines 'fp' as a pointer to a function that takes an integer and a character as parameters and returns an integer.

Step-by-step explanation:

The statement "int (fp)(int,char);" in C/C++ is a declaration of a pointer to a function. The correct interpretation of this statement is option b) fp is a pointer to a function that takes an integer and a character as arguments and returns an integer.

This means that fp can be assigned the address of any function that matches this signature, that is a function that expects an integer and a character as input parameters and returns an integer as the output. It is important to note that the character is passed by value, not as a pointer, which would be denoted with 'char*'.

answered
User Roedy
by
8.5k points