1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
vector<bookData> createArray(int numOBook)
{
vector <bookData> vecBooks;
ifstream data("dataFile.dat");
numOBook--;
cin.clear();
bookData book;
if (!data.good())
cout<<"error opening file."<<endl;
else
{
while(data.good())
{
for(int x=0;x<numOBook;x++)
{
string title,isbn,auth,pub,add;
int qty;
double whole,retail;
getline(data,title,',');
getline(data,isbn,',');
getline(data,auth,',');
getline(data,pub,',');
getline(data,add,',');
data>>qty>>whole>>retail;
book.setTitle(title);
book.setIsbn(isbn);
book.setAuthor(auth);
book.setPub(pub);
book.setDateAdded(add);
book.setQty(qty);
book.setWholeSale(whole);
book.setRetail(retail);
book.isEmpty(true);
vecBooks.push_back(book);
}
}
}
data.close();
return vecBooks;
};
| |