C Programming - Arrays - Discussion

Discussion Forum : Arrays - General Questions (Q.No. 2)
2.
What does the following declaration mean?
int (*ptr)[10];
ptr is array of pointers to 10 integers
ptr is a pointer to an array of 10 integers
ptr is an array of 10 integers
ptr is an pointer to array
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
65 comments Page 2 of 7.

Kumarachary said:   1 decade ago
@Vijayalaxmi is right.

We have to see the priority () have highest priority.

So int (*ptr)[] read it as pointer to array of integers.

If () is not there then int *ptr[] start with [] and it means array of pointers of type integers.
(1)

Balu said:   1 decade ago
First it will read the variable part i.e, (*ptr) and after that it will go anti-clock wise direction then it will read array part([]). Then it will go to before (*ptr)[10]. There is nothing so it will leave.

Abdul Quadir said:   1 decade ago
Int (*ptr)[10];

It's a pointer to an array of 10 integers.

Notice that the array doesn't have a name of its own. We're using the pointer "ptr" to access the array.

The array will be created anywhere in the memory and the only way to access the array is via the pointer "ptr".

Sornalatha said:   1 decade ago
(*ptr) is a pointer. It point out the array of value [10]. So option B is correct.

Vikash kumar said:   1 decade ago
As we know ptr holds the address of variables, and *ptr means what is the value of variables on that address.

Sankar said:   1 decade ago
If any one clear about ptrs please explain clearly. Because I don't understanding anything belong to this.

Sanju said:   1 decade ago
Here ptr is the pointer it is represented by using *...! then the symbol [] shows that it is an array and 10 implies the size of that array.

Tharun said:   1 decade ago
void main()
{
int (*d)[10];
d[0] = 7;
d[1]=10;
printf("%d\n",*d);
}

It should print 10 but compiler is showing error such as follows:

test.c:4:7: error: incompatible types when assigning to type \'int[10]\' from type \'int\'

Amr Gadallah said:   1 decade ago
char *ptr[10]; is an array of 10 pointers to characters.

char (*ptr)[10]; pointer to array of 10 characters.

Abhishek said:   9 years ago
Here, int (*ptr)[10]; - meaning ptr is a pointer to an array of 10 integers.

BUT what will be the NAME of the Array here(which array there is no name given to any array)?


Post your comments here:

Your comments will be displayed after verification.