Hello guys, i need help with this issue, i am trying to read a text file and process it, so i did it, but it read the last line twice and i would like your help to fix it. here is my code:
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
|
void output_label2()
{
ifstream fileReader;
fileReader.open("Mailings.txt");
while(getline(fileReader, name))
{
getline(fileReader, address);
getline(fileReader, city);
getline(fileReader, state);
fileReader >> zipcode;
fileReader >> mailing;
fileReader >> weight;
fileReader.ignore();
fileReader.ignore();
Barcode(); //function
output_label_singleMailing(); //function
}
fileReader.close();
total += postage;
cout << " " << endl;
cout << " " << endl;
cout << "Total cost of all the postage is $"<< total << endl;
}
|
*****Beginning of output********
***********************$0.71
Andy Dwyer
789 Cherry Road
Wamapoke IN 48034
|:|::||::|:||:::::||::|::|:::|||
***********************$0.49
Ben Wyatt
1513 Plymouth Street
Pawnee IN 47407
|:|::||:::|:|::|||:::|:::||::|:|
***********************$2.54
Chris Traeger
8900 Rapport Street
Eagleton IN 47322
|:|::||:::|::||:::|:|::|:|::|:||
Total cost of all the postage is $8.10
***********************$2.54
Chris Traeger
8900 Rapport Street
Eagleton IN 47322
|:|::||:::|::||:::|:|::|:|::|:||
*****End of output ********
you guys can notice that it outputs the info for "Chris Traeger" twice, i would love to eliminate the last one so it should display "Total cost of all the postage is $8.10" only at the end and not that second "Chris Traeger" information.
thank you so much.