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 2 of 7.
Nawinraj said:
7 years ago
Pointer is only pointer to assign array functionto 10 integers.
Anonymous said:
7 years ago
Here [10] is Array of 10 integers and (*ptr) is pointer to point 10 Integers and store Addresses of 10 Integers
And here array name is ptr or same as pointer name.
And here array name is ptr or same as pointer name.
Shruti said:
8 years ago
Given the declaration.
int *ptr[32];
break it down as
ptr -- ptr
ptr[32] -- is a 32-element array
*ptr[32] -- of pointers
int *ptr[32] -- to int.
If the declaration is:
int (*ptr)[32];
then it would break down as
ptr -- ptr
(*ptr) -- is a pointer
(*ptr)[32] -- to a 32-element array
int (*ptr)[32] -- of int.
int *ptr[32];
break it down as
ptr -- ptr
ptr[32] -- is a 32-element array
*ptr[32] -- of pointers
int *ptr[32] -- to int.
If the declaration is:
int (*ptr)[32];
then it would break down as
ptr -- ptr
(*ptr) -- is a pointer
(*ptr)[32] -- to a 32-element array
int (*ptr)[32] -- of int.
Kishor said:
8 years ago
Please explain me.
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)?
Bhuvi said:
8 years ago
@ALL.
#include<stdio.h>
int main()
{
int a=5;
printf("%d %d %d %d %d", a++, a--, ++a, --a, a);
return 0;
}
This depends on the compiler, we don't know the order in which this expression is evaluated is either right to left or left to right.
#include<stdio.h>
int main()
{
int a=5;
printf("%d %d %d %d %d", a++, a--, ++a, --a, a);
return 0;
}
This depends on the compiler, we don't know the order in which this expression is evaluated is either right to left or left to right.
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.
Ankit said:
9 years ago
@Chotu.
When we declare an array, say int a[10];
In above declaration 'a' is acting as a pointer because it holds the base address of array (the location from where it starts storing the values in memory continuously).
But in above example, they just declare the array name as pointer explicitly.
Hence, it is just same as the array declaration on 10 integers.
When we declare an array, say int a[10];
In above declaration 'a' is acting as a pointer because it holds the base address of array (the location from where it starts storing the values in memory continuously).
But in above example, they just declare the array name as pointer explicitly.
Hence, it is just same as the array declaration on 10 integers.
Chotu said:
9 years ago
Explain the answer of this question.
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".
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".
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers