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

Discussion

What does the following declaration mean ? int (*ptr) [10];

  • A.ptr is an array of pointers of 10 integers.
  • B.ptr is a pointer to an array of 10 integers.
  • C.ptr is an array of 10 integers.
  • D.none of the above.

Answer: B

The declaration int (*ptr)[10]; means that ptr is a pointer to an array of 10 integers. The parentheses bind the star to ptr first, so ptr is a pointer, and the [10] then describes the thing it points to.

An array of 10 pointers to integers would be written int *ptr[10], without the parentheses. A plain array of 10 integers would be int ptr[10]. Since the declaration is a valid one with a clear meaning, 'none of the above' is wrong.

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

Post your comment

Please log in or register to post a comment.