Surprisingly, it does compile which is what was making it so hard for me to determine the issue as I'm new to working with outputting to files.
The output I am getting is either 16, or sometimes 16888. May be from other parts of my code?
cDep is the variable used for the amount that the user enters to be deposited into the account they chose and is defined as 'float'
currentDate is what the current computer date is determined in the main() function and is output as a string:
1 2
|
char date[9];
_strdate(date);
|
trans1 - trans5 are the variables used to keep track of the last 5 transactions that are made to the bank account, and when the user enters a new transaction, the string for trans4 goes to trans5, trans3 to trans4 etc and then the user enters the new trans1 name. Then those will all be output to an external file to be read from.
I made the changes you suggested and now it just erases the contents of the file but does not put the new information in, any ideas?
Also, I think there is a problem at line 14, I don't know if strings can be entered that way or no? But I could not see another way of doing that.
EDIT:
I changed trans1 to being just plain text as follows, and it output correctly:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
void cDeposit()
{
system("cls");
cout << "Enter amount deposited:";
cout << "> ";
cin >> cDep;
trans5 = trans4;
trans4 = trans3;
trans3 = trans2;
trans2 = trans1;
trans1= ("DEPOSIT OF $");
ofstream t1file ("trans1.txt", ios_base::out | ios_base::trunc);
if (t1file.is_open() )
{
t1file << (trans1);
t1file.close();
}
}
|
So any ideas on how to include the amount that was entered by the user and the date in the string?