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

Discussion

What’s the meaning of following declaration in C language?

int (*p)[5];

 

  • A.It will result in compile error because there shouldn't be any parenthesis i.e. “int *p[5]” is valid.
  • B.p is a pointer to 5 integers
  • C.p is a pointer to integer array.
  • D.p is a pointer to an array of 5 integers

Answer: D

Correct answer: p is a pointer to an array of 5 integers

The parentheses are what matter. int (*p)[5] binds the asterisk to p first, so p is a pointer, and what it points to is an array of five int. Without them, int *p[5] would be an array of five pointers - the same tokens in a different grouping giving a completely different type.

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

Post your comment

Please log in or register to post a comment.