C Programming - Arrays - Discussion
Discussion Forum : Arrays - General Questions (Q.No. 2)
2.
What does the following declaration mean?
int (*ptr)[10];
int (*ptr)[10];
Discussion:
64 comments Page 3 of 7.
Disha bhatt said:
1 decade ago
Here size of an array is assinged to 10 and * has been used to declare pointer funtion so compiler will automatically consider it as an pointer funtion.Here it simply means it is a pointer funtion consisting of 10 elements.
Arman said:
9 years ago
int (*ptr)[10] - *ptr is a pointer to an array of 10 integers but how?
Because the size of the array is stored in [ ] this form and we seen the 10 is stored [10] like so explain it 10 integer or 10 sizes of the array.
Because the size of the array is stored in [ ] this form and we seen the 10 is stored [10] like so explain it 10 integer or 10 sizes of the array.
Vijayalaxmi said:
1 decade ago
Here 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.
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.
Mayank Dixit said:
1 decade ago
*ptr[10] means 'ptr is an array of pointer type 10 elements'.
(*ptr)[10] means there is an array of 10 elements with no array varaible but 'ptr is pointer type variable' that has base address of that array.
(*ptr)[10] means there is an array of 10 elements with no array varaible but 'ptr is pointer type variable' that has base address of that array.
Gaurav said:
1 decade ago
int (*arr)[10] /* It refers that arr is a pointer to an array of 10 integers*/
and,
int *arr[10] refers to an array of pointers which can hold the starting address of 10 different array of integer data type....
and,
int *arr[10] refers to an array of pointers which can hold the starting address of 10 different array of integer data type....
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.
Divya said:
1 decade ago
int (*ptr)[10];
Start reading what ever is in brackets 1st ,(ptr is a pointer)
Then go towards left till you hit ; (to an array of 10)
Then go backwards and read what ever is left out, (integers).
Start reading what ever is in brackets 1st ,(ptr is a pointer)
Then go towards left till you hit ; (to an array of 10)
Then go backwards and read what ever is left out, (integers).
Srilakshmi said:
1 decade ago
Array size is represented in []ie. , no. Of elements contained in it * represents for a pointer so ptr is a pointer to an array of 10 integers since the return type is specified as int.
Chris said:
1 decade ago
#include<stdio.h>
int main()
{
int a=5;
printf("%d %d %d %d %d", a++, a--, ++a, --a, a);
return 0;
}
// Ans : 4 5 5 4 5
Can any one explain the above code please ?
int main()
{
int a=5;
printf("%d %d %d %d %d", a++, a--, ++a, --a, a);
return 0;
}
// Ans : 4 5 5 4 5
Can any one explain the above code please ?
Abhishek said:
8 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)?
BUT what will be the NAME of the Array here(which array there is no name given to any array)?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers