I'm trying to get a print out of inventory items, so that it prints out the items prefixed with 1. 2. 3. etc.
I'm not sure how best to loop through these kind of arrays, so I tried a stupid fix with the currentinv variable which I'm sure is unnecessary
If anyone can suggest the best loop code for the display inventory function I'd be grateful
struct character
{
string name;
unsigned short int health = 100;
unsigned short int currentinv = 4;
string inventory[10] = {"Gun", "Knife", "Blade"};
} player;
void displayinventory()
{
string *elem = &player.inventory[0];
for (unsigned short int i = 1; i < player.currentinv; ++i)
{
cout << "\n" << i << ". " << *elem << "\n\n";
++elem;
}
}