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".
"An array of three pointers to chars".
Discussion:
19 comments Page 1 of 2.
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];
Bhavani said:
1 decade ago
Yes (*ptr)[3] is correct.
Tamil said:
1 decade ago
Yes. You are right. Ptr is the array which contains 3 character pointer.
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
int *(ptr[20]); It is the pointer to array of 10 elements
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..
*(ptr[3])is a pointer to array of 3 elements
where as *ptr[3] is an array consists of 3 pointers.
agreed with nagraj..
Raj said:
1 decade ago
Option b is absolutely correct no discussion at all.
Richa Rao said:
1 decade ago
It must be *ptr[2] as index start from 0th position.
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
*(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
Raju said:
1 decade ago
char *ptr[3] is correct. There is 3 characters are defined in pointers.
Ankita said:
1 decade ago
In option (A) *ptr[3](); is a function means every pointer value is work as a function.
In optinc (c) (*ptr[3])(); is a complete pointer function.
In option (D) defines the pointer of pointer of array.
So,finally option(B) is correct,which gives "An array of three pointers to chars".
In optinc (c) (*ptr[3])(); is a complete pointer function.
In option (D) defines the pointer of pointer of array.
So,finally option(B) is correct,which gives "An array of three pointers to chars".
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers