i'm trying to get this code working with no success the past week. Actually it is a mess and i don't know which way to run. Here's a part of my code:
void mfy_st(ifstream& FILE_E, ofstream& FILE_O)
{
int option = 0;
double amount;
char unit;
currency curr;
cout<< "1- Enter cash \n"<<"2- Withdraw \n";
cin>>option;
switch(option)
{
case 1:
cout<<"Enter the amount you would like to enter, followed by the unit: \n";
open_file();
cin>>amount>>unit;
curr.amount = amount;
curr.unit = unit;
FILE_E<<curr.amount<<curr.unit;
FILE_E.close();
break;
case 2: cout<<"Enter the amount you would like to withdraw, followed by the unit: \n";
open_file();
cin>>amount>>unint;
curr.amount = amount;
curr.unit = unit;
FILE_O<<curr.amount<<curr.unit;
FILE_O.close();
break;
default:
cout<<"Option invalid";
break;
}
}
I'm having problem writing on the files. And the compiler throws error: no match for 'operator<<' (operand types are 'std::ifstream {aka std::basic_ifstream}' and 'double').
I know the code is a bit messy, I'll fix that when the program works! Hope you can help me.