Also the Items are displayed as address location instead of regular text forum. I've tried adding & to line 70 infront of StoreVec, no difference.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int Size = 3; // Max directories
const int InvSize = 4; // Max items per Store
struct Store
{
int ID;
string title[InvSize]; // 3 members per Store.
};
void SetDefaults (vector <Store> & , const int [], const string [][InvSize], int);
void DisplayVector (const vector <Store> &);
int main()
{
vector<Store> items;
const int Directory [Size ] ={ 101, 102, 103};
const string Inventory [] [InvSize] = { {"Black", "Cyan", "Magenta", "Yellow"},
{"OHV", "SOHC", "DOHC", "QOHC"},
{"Password", "Keycard", "Token", "Retina"}, };
SetDefaults(items, Directory , Inventory , Size);
DisplayVector(items);
system("pause");
return 0;
}
void SetDefaults (vector <Store> & StoreVec, const int dir[],
const string inv[][InvSize], int size)
{
for (int i = 0; i < size; i++)
{
Store temp;
temp.ID = dir[i];
StoreVec.push_back(temp);
for (int i2 = 0; i2 < InvSize; i2++)
{
temp.title[i2] = inv[i][i2];
StoreVec.push_back(temp);
}
}
}
void DisplayVector (const vector <Store> & StoreVec)
{
cout << "Display current...\n" << endl;
for (int i = 0; i < Size; i++) // Changing to for (int i = 0; i < 10; i++) ,for examples, there at least 6 copies of each ID/Directory.
{
cout << "Store " << (i+1) << ": \nID: " << StoreVec[i].ID << " Itemss";
for (int i2 = 0; i2 < InvSize; i2++)
{
cout << " " << StoreVec[i2].title << " "; // Changing i2 to i, each row, instead of column, has identical Items address
}
cout << endl << endl;
}
cout << endl;
}

New Topic/Question
Reply



MultiQuote





|