I have this code where I read in a file with a getline to get the originaly balance of a checkbook type document. After that, the .txt.file is set up to read the date, debit or credit transaction type, amount, description of credit/debit. I keep getting an error dealing with the 'Entry.' parts of my code. Not sure what the problem is. Can someone take a look and see if they know whats going on. Is something messed up with my code somewhere. There are one or two more minor errors something to do with the action == part of the code. Any help would be great. Thanks
Code:
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
typedef struct Entry
{
string date, action;
float amount;
string descript;
}Entry;
int main()
{
string name;
float balance;
ifstream fin;
ofstream fout;
cout << "enter the name of the Checkbook filename: " << endl;
cin >> name;
fin.open(name);
fin >> balance;
while (!fin.eof())
{
fin >> Entry.date >> Entry.action;
fout << Entry.date << Entry.action;
if (action == "credit")
{
fin >> Entry.amount;
fout << Entry.amount;
balance = balance + Entry.amount;
}
else if (action == "debit")
{
fin >> Entry.amount;
fout << Entry.amount;
balance = balance - Entry.amount;
}
getline(fin, descript);
fout << descript;
}
fout << balance;
}//end main