C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - General Questions (Q.No. 1)
1.
Declare the following statement?
"An array of three pointers to chars".
char *ptr[3]();
char *ptr[3];
char (*ptr[3])();
char **ptr[3];
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
19 comments Page 2 of 2.

Raju said:   1 decade ago
char *ptr[3] is correct. There is 3 characters are defined in pointers.

Kavinder singh said:   1 decade ago
Yes b option is correct *ptr[3]
*(ptr[3])is a pointer to array of 3 elements
where as *ptr[3] is an array consists of 3 pointers.
agreed with nagraj and nishu

Richa Rao said:   1 decade ago
It must be *ptr[2] as index start from 0th position.

Raj said:   1 decade ago
Option b is absolutely correct no discussion at all.

Nishu nishant said:   1 decade ago
Yes b option is correct *ptr[3]
*(ptr[3])is a pointer to array of 3 elements
where as *ptr[3] is an array consists of 3 pointers.
agreed with nagraj..

Nagaraj said:   1 decade ago
char *ptr[3]; It is an array wich consists of pointers.
int *(ptr[20]); It is the pointer to array of 10 elements

Tamil said:   1 decade ago
Yes. You are right. Ptr is the array which contains 3 character pointer.

Bhavani said:   1 decade ago
Yes (*ptr)[3] is correct.

Dhiraj said:   1 decade ago
What you have marked as answer is a pointer to an array of three character the correct answer will be char (*ptr)[3];


Post your comments here:

Your comments will be displayed after verification.