Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following statements correctly declare a function that receives a pointer to pointer to a pointer to a float and returns a pointer to a pointer to a pointer to a pointer to a float?

  • A.float **fun(float***);
  • B.float *fun(float**);
  • C.float fun(float***);
  • D.float ****fun(float***);

Answer: D

Correct answer: float ****fun(float***);

Read the declaration outward from the name. The parameter is a pointer to a pointer to a pointer to a float, so it is written float ***. The return type is one level deeper again, so it is float ****.

Count the asterisks against the words: three for the parameter, four for the return. The other options mismatch one or both. Where such declarations become unreadable, a typedef for the intermediate types is the usual remedy.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.