//Rob Gross
//assignment3
//5/4/02

#include<iostream>
#include<fstream.h>
#include <process.h>

void main()
{
    char Name[21];
    float Owes;
    fstream customers;

    customers.open("customers.txt", ios::in | ios::out | ios::trunc);
    if (!customers)
    {
	cout << "Cannot open file - customers.txt";
	exit(1);
    }
	cout << "Enter customers number (blank to exit): ";
	cin.get();
	customers << Name << endl;
    while (Name[0] != '\0' )
	{
	    cout << "Enter amount owed: ";
	    cin >> Owes;
	    cin.get();
		
		cout << "Enter customer's name : ";
		cin.getline(Name, 21);

		cout << "Enter amount owed: ";
	    cin >> Owes;
	    cin.get();
    }

    //customers.seekg(0,ios::beg);
	customers.seekg(0);

    cout << "\n\nThis is the text in the file\n";
    customers.getline(Name, 80);
    while ( !customers.eof() )
    {
	    customers >> Owes;
        customers.ignore(); //ignore the LF character
	    cout << Name << "  : " << Owes << "\n";
	    customers.getline(Name, 80);
    }
    customers.close();
}