I am trying to read a text file in virtual void BillRecord::ReadCustDetails(ifstream &fin)
that contains customer details. Codes works fine but I dont know how to read even the whole address and negative values and store them to private members. I have tried the following code but the output is wrong.
text file:
Phone
Origin
George Carter
24 Dingo St Exeter SA
-0.018
28
Gas
EA
Paul Scott
21 Beach Rd Barham NSW
15.48786
356567
Elect
...
my output:
Origin
George
Carter
0
24
Required output:
Origin
George Carter
24 Dingo St Exeter SA
-0.018
28
My program:
public:
BillRecord();
virtual void ReadCustDetails(ifstream &fin);
private:
BillType BType;
string Supplier; // Supplier's name
string Name, Address; // Customer's name and address
double BillAmount;// Amount in dollars and cents of this bill
int DaysSinceLastReading; // Days since last reading
};
virtual void BillRecord::ReadCustDetails(ifstream &fin)
{
fin >> Supplier;
getline(fin,Name);
getline(fin,Address);
fin >>AccountBalance;
fin >>BillAmount;
fin >>DaysSinceLastReading;
fin >>i;
DaysSinceLastReading=i;
//put the code here for reading the customer details part of the file
record only into the private data members
cout << Supplier<< endl;
cout << Name << endl;
cout << Address << endl;
cout << BillAmount << endl;
cout << AccountBalance << endl;
}