I have a program that I am doing that is supposed to take lines from a text file and read them, line by line. My program works well for the first line, but stops and does not read the last three. This is the code I have so far:
ifstream inputfile;
ofstream outputfile;
inputfile.open("test.txt");
outputfile.open("invoice.txt");
while (!inputfile.eof())
{
inputfile >> cust_id;
inputfile >> title;
inputfile >> author;
inputfile >> isbn;
inputfile >> isbn2;
inputfile >> isbn3;
inputfile >> isbn4;
inputfile >> price;
inputfile >> quanity;
inputfile >> type;
inputfile >> genre;
outputfile << "____________________________________________________________________________________________________________" << endl;
outputfile << "Invoice" << endl;
outputfile << " " << endl;
outputfile << "Customer ID: " << cust_id << endl;
outputfile << title << " " << fiction_type << " " << genre_type << " " << quanity << "@" << price << " " << "subtotal: " << subtotal << endl;
outputfile << " " << endl;
outputfile << "Total book sales: " << subtotal << endl;
outputfile << "Tax: " << totaltax << endl;
outputfile << "Subtotal: " << subtotal_withtax << endl;
outputfile << "Fee: " << fee << endl;
outputfile << "Total: " << total_price << endl;
cout << "something" << endl;
inputfile.close();
return 0;
}
I have taken part of the code out because it is not needed, it is just using different if/elif loops to validate data.
The file I am attempting to read is:
234 Dog_Strategy Henry_Moreno 3-598-21500-2 12.99 5 N M
6789 Companion_Kicked_Me_Out Lorraine_Johnson 3-598-21599-1 24.99 3 F R
3444 Mime_On_My Journey Kristy_Wahl 3-699-21500-8 6.75 10 N D
4455 Damaged_By_The_Joke Henry_Christopher 3-598-21500-2 12.99 4 N R
When I execute my code, it does the first line perfectly but will not read the last three and I cannot figure out why. Any help would be awesome.