What is the meaning of the following declaration in C programming language?…

2018

What is the meaning of the following declaration in C programming language?

int (*p)[5];

  1. A.

    It will result in compile error because there should not be any parenthesis, i.e., "int *p[5]" is valid

  2. B.

    p is a pointer to 5 integers

  3. C.

    p is a pointer to integer array

  4. D.

    p is a pointer to an array of 5 integers

Attempted by 128 students.

Show answer & explanation

Correct answer: D

  • The Parentheses Matter: In C, the array subscript operator [] has higher precedence than the pointer operator *. By enclosing *p in parentheses (*p), we force the compiler to bind the pointer operator to p first.

  • Decoding int (*p);:

    1. Look inside the parentheses: (*p) means p is a pointer.

    2. Look outside to the right: `` means it points to an array of 5 elements.

    3. Look to the far left: int means those elements are of integer data type.

Putting it all together: p is a pointer to an array of 5 integers.

Explore the full course: Up Lt Grade Assistant Teacher 2025