Not sure if this is possible, but I am trying to make a data structure that contains all the elements I need, so I can loop through them and initialize them.
for (i = 0; i< item_number; i++)
{
allstructs*.attr2 = i;* }[/quote] So I have to set only a limited amount of properties for each entry in the array. Although I may not know which item is at position 1, 2 or whatever other position in the array, so my question is: can I use the name of the variable (item1, item2 and so on), instead of the position in the array? So I can do something like > allstructs[item1].attr1 = "x";
I get your point, and the enum option is feasible. I have to try the implementation.
The reason for giving names? It exist even if you use an array. Consider the case where you have a struct that identify a type of element, like a dog. You want to have a cluster of dogs, so you can parse them all and see for example, who has a microchip.
If I have an array of dogs; I can read or write on their microchip in sequence, because they have common properties, but they have also different properties (their name, their breed, their size); some of which are unique, while other are relevant only to a subset of them.
Of course there are other ways to do this; I was just pointing out why it make sense for me to go in that route; I am not stating that this is the only way. I do use other languages; and sometimes you get used to what you do in a different language, and subconsciously do the same for all the other languages.