Hello all,
I am working on a program that will read a text file cpart.dat. I want to use a void getData function that I can call in main. I’m having problems to say the least. Here is what I have so far, also: I'm thinking I want to use push_back function in “while (inp)”, to add data to my vectors. Any help would be greatly appreciated
Here is what I have so far:
Code:
void getData(ifstream& inp, vector<int>& itemIDs, vector<string>& itemNames,
vector<int>& pOrdered, vector<int>& pInStore,
vector<int>& pSold, vector<double>& manufPrice,
vector<double>& sellingPrice)
{
int id;
string name;
int itemsOrdered;
double mPrice;
double sellPrice;
char ch;
inp >> id; // Read item id
inp.get(ch); // Read a newline
getline(inp, name); // Read item name
inp >> itemsOrdered >> mPrice >> sellPrice; // Read other info of the item
while (inp)
{
// read the remaining items
}
}