Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,393 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,140 people online right now. Registration is fast and FREE... Join Now!




Creating an Array of Pointers.

 
Reply to this topicStart new topic

Creating an Array of Pointers.

eudos
7 Sep, 2006 - 06:28 AM
Post #1

D.I.C Head
**

Joined: 23 Apr, 2006
Posts: 58


My Contributions
Hi..

I have a question about arrays and pointer..first i will explain what i am trying to do..

I am tryin to create a "struct" which contains an "array of pointers" and an int which counts the amount in array.

the thing i don't understand is that the pointers in that array is pointing to another "strcut"(s) and how can i type define that..Is the way i defined is Correct.. here is the code below;
CODE

struct field{
   int numHoles;
   Hole *PointersToHoles[N]
}


Here is the sturct called hole is defined;
CODE

typedef struct {
   blaa..
   blaa..
  
}Hole;



Plz tell me whether the above way of defining this part "Hole *PointersToHoles[N]" is correct. I just want to make sure before i go furthur with my code.. there is a lot to write. this is just the base of my Program.

Thanks smile.gif
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Creating An Array Of Pointers.
7 Sep, 2006 - 07:12 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,985



Thanked: 45 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Close but you need the struct identifer, like this:
CODE

struct field{
   int numHoles;
   struct Hole *PointersToHoles[N];
}

You may have a problem since N has not been defined. You might have to use a static number.
CODE

struct Hole *PointersToHoles[18];

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:39AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month