I'm using a for loop to read in data from a file and store the values in class members:
while (!bookstxt.eof())
{
for (int i = 0; i < x; i++) {
getline(bookstxt, title);
getline(bookstxt, author);
getline(bookstxt, publisher);
getline(bookstxt, isbn);
cin.clear();
cin.ignore(100, '\n');
bookstxt >> price >> year >> numInStock;
cout << title << "\n" << author << "\n" << publisher << "\n" << isbn << "\n" << price << "\n" << year << "\n" << numInStock;
bookList[i].storeBook(title, author, publisher, isbn, price, year, numInStock);
}
}
The issue I'm having an issue with the ISBN part - it does what it needs to do correctly the first time around the loop, but on the second time it screws up the isbn and somehow pushes part of it to the next two variables. Here's what the output should look like for the line that breaks
The World is Flat
Friedman, Thomas
Farrar, Straus and Giroux
0-374-29279-5
30.00
2006
12
Here's what actually happens:
Starting Out with C++
Gaddis, Tony
Pearson
978-0-13-257625-3
129.98
2014
25
The World is Flat
Friedman, Thomas
Farrar, Straus and Giroux
0
-374
-29279
-5
30.00
2006
12
0
-374
-29279
It seems to screw up somewhere around reading the ISBN part. Would appreciate any assistance