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

Discussion

Which of the following statements correct about k used in the below statement?
char ****k;

  • A.k is a pointer to a pointer to a pointer to a char
  • B.k is a pointer to a pointer to a pointer to a pointer to a char
  • C.k is a pointer to a char pointer
  • D.k is a pointer to a pointer to a char

Answer: B

Correct answer: k is a pointer to a pointer to a pointer to a pointer to a char

Each asterisk adds one level of indirection, so four asterisks give four levels: k is a pointer to a pointer to a pointer to a pointer to char.

Counting the asterisks is the whole technique for reading such declarations. In practice more than two or three levels are rare outside argument-vector manipulation and certain data structures, and where they arise a typedef for the intermediate levels usually makes the code readable.

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

Post your comment

Please log in or register to post a comment.