|
1 registered members (1 invisible),
1,498
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Array of pointers to structures.
#348902
12/01/10 17:27
12/01/10 17:27
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Hey guys I'm having a but of a problem. I hope it doesn't get to confusing so I'll try to explain it as simple as possible. I'm trying to make a pretty complicated inventory system and in order to do so each item slot needed a struct. I then wanted to keep the different items organized inside another struct (the inventory). The best way I could think of doing this was to create an array where each array element was a pointer to an item. I'm having a real hard time defining this can someone help please I keep getting syntax errors.
typedef struct {
int itemNum;
int itemID;
int iSpell;
int minD;
int maxD;
int arm;
int quant;
int pref;
int suf;
int sock1;
int sock2;
int sock3;
} _item;
typedef struct {
_item* item[31];
}_inventory
Last edited by PrenceOfDarkness; 12/01/10 17:50.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: Array of pointers to structures.
[Re: PrenceOfDarkness]
#348904
12/01/10 17:36
12/01/10 17:36
|
Joined: Oct 2009
Posts: 149 Germany
muffel
Member
|
Member
Joined: Oct 2009
Posts: 149
Germany
|
Last line where is a semicolon missing. Error messages would help.
EDIT: I don't understand your way how you want to organize the items.
muffel
Last edited by muffel; 12/01/10 17:37.
|
|
|
Re: Array of pointers to structures.
[Re: muffel]
#348909
12/01/10 17:52
12/01/10 17:52
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
yea I muffel I'm sorry it's a bit complicated, that's why I was a afraid of even asking on here. I'm trying to think of a better way to word it but I can't come up with one.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: Array of pointers to structures.
[Re: PrenceOfDarkness]
#348913
12/01/10 18:49
12/01/10 18:49
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Your concept is completely right and there is nothing wrong with the code, except of the missing semicolon at the end. It compiles fine here and works like expected, so you probably just redefined something existing or did some other things wrong? The Lite-C compiler isn't a real help when trying to track down the correct line which causes the error.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Array of pointers to structures.
[Re: WretchedSid]
#348928
12/01/10 21:41
12/01/10 21:41
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Thank you so much Sid you were completely right! thank you!
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
|
|
|