C Programming - Complicated Declarations - Discussion

Discussion Forum : Complicated Declarations - General Questions (Q.No. 3)
3.
Declare the following statement?
"A pointer to an array of three 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:
10 comments Page 1 of 1.

Kingli said:   4 years ago
@All

We know that ptr points to addr of the first index of the array. In order to point the ptr to every index of the array, we have to use ptr of the array such that *ptr[00]-->arr[0]
*ptr[1]-->arr[1] and so on .

Correct me if I am wrong.

Vanitha attada said:   8 years ago
Here, we have an array of 3 characters char a[3], we have to assign a pointer to whole elements of the array. So * in the parenthesis. And ptr is the pointer to an array. The Combination of these we will get char (*ptr) [3].

Ahmed said:   9 years ago
What is char (*ptr)*[3] ;?

Please describe it.

Dev said:   1 decade ago
If we write ptr++, what will happen ?

Arjun said:   1 decade ago
What will be the name of array? how can we enter values in this array?

Dishendra said:   1 decade ago
See if there was no star symbol then it would have been, array of 3 character. Now since since star is within parenthesis that operation is applied to whole array. So, it is pointer to array of 3 characters.

Ganesh said:   1 decade ago
Here we should have 3 characters only but not pointers. To declare any pointer we can have the syntax like char a[3]. So here a is an array which can contain 3 characters. We are asked for pointer to array of 3 characters. So to declare it char (*ptr) [3] is the correct one. Where ptr is a pointer to an array which contains 3.

Anjali said:   1 decade ago
Here we should have 3 characters only but not pointers. To declare any pointer we can have the syntax like char a[3]. So here a is an array which can contain 3 characters. We are asked for pointer to array of 3 characters. So to declare it char (*ptr) [3] is the correct one. Where ptr is a pointer to an array which contains 3.

Guest said:   1 decade ago
An array of 3 characters is declares as a pointer this way only.

Vishakan said:   1 decade ago
Hi could any one help me how?

Post your comments here:

Your comments will be displayed after verification.