Hello again, I'm trying to finish a function I am working on that reads data from a file set up like:
itemID
itemName
pOrdered manufPrice sellingPrice
itemID
itemName
pOrdered manufPrice sellingPrice
....and so on
and puts the data into vectors
this is what I've gotten so far and I'm not sure I am going about this in the right way, the difference between using arrays and vectors is confusing the heck out of me; pSold is supposed to be 0 initially and pInStore is supposed to be the same as pOrdered, that is why they are not in the input file. Any further guidance would be greatly appreciated.
void getData(ifstream& infile, vector<int>& itemID, vector<string>& itemName, vector<int>& pOrdered, vector<int>& pInStore, vector<int>& pSold, vector<double>& manufPrice, vector<double>& sellingPrice)
{
int sold = 0;
string name;
int id, ordered;
double mPrice;
double sPrice;
char ch;
infile >> id;
infile.get(ch);
getline(infile, name);
infile.get(ch);
getline(infile, ordered, mPrice, sPrice);
while (infile)
{
itemID.pushback(id);
itemName.pushback(name);
pOrdered.pushback(ordered);
pInStore.pushback(ordered);
pSold.pushback(sold);
manufPrice.pushback(mPrice);
sellingPrice.pushback(sPrice);
}
}