C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - General Questions (Q.No. 12)
12.
What do the following declaration signify?
int (*ptr)[30];
ptr is a pointer to an array of 30 integer pointers.
ptr is a array of 30 integer function pointer.
ptr is a array of 30 integer pointers.
ptr is a array 30 pointers.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
14 comments Page 2 of 2.

Ferozee said:   1 decade ago
Pointer Array Concept i.e., *p[30] is pointer Array,means *p points to 30 integers of an Array.

Jegadees said:   1 decade ago
Pointer array concept

Ritesh anand said:   1 decade ago
Friends its a very simple one. int (*ptr) is nothing but a ptr which points to some single integer value.

Now int (*ptr)[30] is something interesting here u are declaring not one pointer to point some integer value.

Here you are declaring 30 pointers to point some integer values and these 30 pointers are stored in array and that's why int (*ptr)[30] is an array of 30 integer pointers.

Bishop said:   9 years ago
int *ptr[30]; //an array of 30 pointers (equivalent: int* ptr[30];).

int (*ptr)[30]; //a pointer to an array of 30 elements (int).

int *(*ptr)[30]; //a pointer to an array of 30 pointers (equivalent: int* (*ptr)[30];).


Post your comments here:

Your comments will be displayed after verification.