Reputation: 13
What is the array of pointer to the structure?
is it something like this:
StructureName objectname[size];
int *ptr;
ptr=objectname;
Please confirm me with this.
Upvotes: 0
Views: 71
Reputation: 110658
I'm assuming you meant ptr
to be a StructureName*
, otherwise your code won't compile.
No, that is not an array of pointers to a struct. What you have done is used array-to-pointer to conversion to assign the array objectname
to ptr
. This makes ptr
a pointer to the first element of the array.
An array of pointers to struct is something like:
StructureName* objectname[size];
Here, we are declaring an array objectname
that has size
pointers to StructureName
s. The elements of the array are pointers. This makes it an array of pointers.
On the other hand, your title asks about a pointer to an array of structs, in which case it would look like this:
StructureName (*objectName)[size];
Upvotes: 0
Reputation: 76240
This is the array of pointers to some structure:
StructureName* objectname[size];
// ^
which is the closest thing I can think of when you refer to:
array of pointer to the structure
Upvotes: 1