Array of pointers to structures.

Posted By: PrenceOfDarkness

Array of pointers to structures. - 12/01/10 17:27

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.
Code:
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


Posted By: muffel

Re: Array of pointers to structures. - 12/01/10 17:36

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
Posted By: PrenceOfDarkness

Re: Array of pointers to structures. - 12/01/10 17:52

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.
Posted By: WretchedSid

Re: Array of pointers to structures. - 12/01/10 18:49

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.
Posted By: PrenceOfDarkness

Re: Array of pointers to structures. - 12/01/10 21:41

Thank you so much Sid you were completely right! thank you!
© 2024 lite-C Forums