I am trying to write a program that cerate’s a in invoice. And i am trying to use cin.eof() for the program to recognise when the input file has come to an end…
Code:
int main(int argc, char *argv[])
{
    int quantity, numberOfItems; float price, itemTotal, total=0; string productID;
    
    cout << "PHANTOM COMPAY INVOICE\n\n"
         << "PRODUCT ID   QUANTITY   PRICE   PRICE\n\n";

    while (cin.eof())
    {
        cin >> productID >> quantity >> price;         // Read values from invoic.dat
        itemTotal = quantity*price;                    // calculate total cost for items
        cout << productID << setw(18-productID.size()) // display product id
             << quantity << setw(11)                   // display quantity
             << price << setw(8)                       // display price for one item
             << itemTotal << endl;                     // display price for all items 
        total = total + itemTotal;                     // calculate cost of all items
    }
    
    cout << endl
         << setw(34) << "TOTAL: " << total;        // display total cost of all items
        
    return EXIT_SUCCESS;
}
And this is the file I am trying to input from.
Quote Originally Posted by purchase.dat
Pro123 5 25
Pro152 4 15
Pro152 4 24
Pro152 5 10
Pro152 4 9
and I am using this bat file I created to run the program
Quote Originally Posted by Invoice.bat
@echo off

echo PHANTOM COMPAY INVOICE
echo Makeing Invoice, Output File "Statment.txt"

invoice.exe < purchase.dat > statment.txt
pause
for my output all i get is
Quote Originally Posted by statment.txt
PHANTOM COMPAY INVOICE

PRODUCT ID QUANTITY PRICE PRICE


TOTAL: 0