Program Compiles but does not read proper file....
I have this code, and it compiles - it asks for the file to look at to get the information from and I type in the file which is account and i also tried account.txt and then it doesn't do anything else. It says press any button to continue and then exits out of everything. I'm not sure whats going on.
Can anyone help me????? Thanks
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct Entry
{
string date, action;
float amount;
string descript;
}Entry;
int main()
{
string name, date, action, descript;
float balance, amount;
ifstream fin;
ofstream fout;
cout << "enter the name of the Checkbook filename: " << endl;
cin >> name;
//string update(name);
//update.append(".update");
fin.open(name.c_str(), ios::in);
fin >> balance;
while (!fin.eof())
{
fin >> date >> action;
//cout << date << action;
fout << date << action;
if (action == "credit")
{
fin >> amount;
fout << amount;
balance = balance + amount;
}
else if (action == "debit")
{
fin >> amount;
fout << amount;
balance = balance - amount;
}
getline(fin, descript);
fout << descript;
}
fout << balance;
fin.close();
//fout.close();
}//end main