C Programming - Complicated Declarations - Discussion
Discussion Forum : Complicated Declarations - General Questions (Q.No. 2)
2.
What do the following declaration signify?
int *ptr[30];
Discussion:
12 comments Page 1 of 2.
George said:
1 decade ago
[B]. ptr is a array of 30 pointers to integers.
[C]. ptr is a array of 30 integer pointers.
B and C are correct. pointers to integers and integer pointers are the same. For those brand new to coding and with weak english skills , this will be really confusing!
[C]. ptr is a array of 30 integer pointers.
B and C are correct. pointers to integers and integer pointers are the same. For those brand new to coding and with weak english skills , this will be really confusing!
(1)
Shilpa said:
1 decade ago
Let p is a pointer.
Declaration:
int a;
int *p=&a;//i.e p points to the content present in address of a...
So in the similar manner,*p[2] points to the address of some to variables say a ,b..
In the similar manner *p[30] points to 30 integer variables.
Declaration:
int a;
int *p=&a;//i.e p points to the content present in address of a...
So in the similar manner,*p[2] points to the address of some to variables say a ,b..
In the similar manner *p[30] points to 30 integer variables.
HITESH said:
1 decade ago
No Ankur,the answer is only B coz when we declare
int *p;
then it means u declare p is a pointer to integer n when u declare
int ptr[30];
ptr is an array name to integer n here..
int *ptr[30];
ptr is a array of 30 pointers to integers.
int *p;
then it means u declare p is a pointer to integer n when u declare
int ptr[30];
ptr is an array name to integer n here..
int *ptr[30];
ptr is a array of 30 pointers to integers.
Omka akash said:
5 years ago
int *ptr[30]; (array of pointrs)=> ptr is array of 30 integer pointers.
Because square braces having more priority than * operator.
int (*ptr)[30];(pointer to an array)=> ptr is a pointer pointing to an array of 30 integers.
Because square braces having more priority than * operator.
int (*ptr)[30];(pointer to an array)=> ptr is a pointer pointing to an array of 30 integers.
(1)
Vilas said:
1 decade ago
Yes.int *p;
then it means u declare p is a pointer to integer n when u declare
int ptr[30];
ptr is an array name to integer n here..
int *ptr[30];
ptr is a array of 30 pointers to integers.
then it means u declare p is a pointer to integer n when u declare
int ptr[30];
ptr is an array name to integer n here..
int *ptr[30];
ptr is a array of 30 pointers to integers.
Utkarsh said:
6 years ago
In declaration:
int p[20][30]; -> 20 elements each of which is an array of 30 ints.
is equivalent to int *p[30];
So, p is a pointer to an array of 30 ints.
int p[20][30]; -> 20 elements each of which is an array of 30 ints.
is equivalent to int *p[30];
So, p is a pointer to an array of 30 ints.
Monika said:
1 decade ago
int *ptr[30];
it is an array of size 30 that contain integer pointer i.e.
array of 30 pointers to intger.
it is an array of size 30 that contain integer pointer i.e.
array of 30 pointers to intger.
Shine said:
1 decade ago
B and C both are same I guess. Integer pointer and pointer to integer means same. Somebody please confirm.
(1)
Sona said:
1 decade ago
A should be the answer. Because ptr is a pointer to an array of three integer to pointer.
Tejas said:
6 years ago
A should be the answer. Because ptr is a pointer to an array of thirty integers.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers