Ok, so let's say I have a struct made up of 4 elements and then I send a series of these structs to a vector and now I want to loop the vector through to print out each element of the struct individually. Is this possible? I was writing a function for this earlier and ran into a snag, does anyone have any ideas? Any help would, as always, be greatly appreciated. Below is the struct I've created as well as the function that prints the vector (the structs have already been written into the vector at this point).
In any case: for(int mult = 1; (mult * 5) == 50; mult ++)
mult*5 is 5 and 5!=50, so the loop body will never run. I don't know what you're trying to do, but I doubt this was intended.
You're right about that, thanks for pointing it out but the snag is that I can't get this function to compile, because I don't know if it's possible to access just one element of a struct within a vector like I'm trying to do throughout it.
Is the format I'm using correct? For example, would cout << items.item.cost[count] print the cost element of the item struct of the count index? Or do I have to do it some other way, or is it even possible at all?
Oh, I see my problem now, my index is in the wrong spot instead of items.item.cost[count], it should really be items[count].cost, but thanks again for pointing out that other detail.