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 6 of 7.
Ganesh said:
1 decade ago
*ptr is a pointer and[10] is array declarations.
Purna chandra said:
1 decade ago
Yes p is pointer of 10 integers.
Balaji said:
1 decade ago
Can you explain me the concept?
Subaidha said:
1 decade ago
* means its represent as a pointer variable and here within a array bracket they give us 10 integers.
So that the ans is B.
So that the ans is B.
Nagaraj said:
1 decade ago
The below program explains tat the starting address of the array. so it is [int (*ptr)[5];] is a pointer to array not array pointer which can be declared by int *ptr[5];
#include<stdio.h>
int main()
{
int arr[5];
int (*ptr)[5];
ptr=&arr[10];
printf("%ld",ptr[5]);
return 0;
}
#include<stdio.h>
int main()
{
int arr[5];
int (*ptr)[5];
ptr=&arr[10];
printf("%ld",ptr[5]);
return 0;
}
Neeraj awasthi said:
1 decade ago
If () is not there then int *ptr[] start with [] and it means array of pointers of type integers.
Gautam jangra said:
1 decade ago
int (*ptr)[10]
also we can write it as
int *ptr[10]
this line says that ptr is a pointer type variable which stores the address of first element of a 10 elements array list
as we know that array is continous memory type allocation.....
also we can write it as
int *ptr[10]
this line says that ptr is a pointer type variable which stores the address of first element of a 10 elements array list
as we know that array is continous memory type allocation.....
Kuldeep chaudhary said:
1 decade ago
pointer of array is declared as type (*p)[14]
array of pointers is declared as type *p[14]
array of pointers is declared as type *p[14]
Avijit said:
1 decade ago
ptr is a pointer,which is a type of int.ptr is an 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.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers