Hello I'm Tobi and how u can see im from Poland ^_^ -> TobiPL ( PL -> Poland :D )
thats why my English is bad ;c... Sorry...
i wanna make my Code Better but idk How... Look:
<code>
struct WorldObject
{
int posx,
posy;
short type;
};
struct World{WorldObject Object[50];};
World Test[3][3];
</code>
How u can see i have Struct named "WorldObject" and Every object have PosX , posY and Type ( ID to Graphics )
and i have another Struct names "World" and inside this Struct i have 50 Objetsc from struct "WorldObject"
and now my Problem... how can i set different Amount of "WorldObject" in evey "cell" in "world"
something like:
World Test[1][1] have 30 World Objects
World Test[1][2] have 100 World Objects
World Test[1][3] have 50 World Objects..
i was trying with something like this:
<code>
Struct World
{
int Amount;
WorldObjects[Amount];
}
</code>
but i got Error ;/...
(Assuming this is C or C++.) You can only declare arrays to be of a fixed (const) length. Also the syntax of that declaration isn't right anyway.
So for example you could declare: const int max_amount_c = 50; if you knew that was the largest a world cell could be. And then it would be: WorldObject WorldObjects[max_amount_c];
More generally you need to dynamically allocate an array and use a pointer, to allow arrays of arbitrary length.
If you're using C++, I'd recommend using something like the vector class.