Hey, in line 24th void print I don't want to use p and int parameters because I'm not using them for printing only the value that I got from line 18th function. However, I'm calling a function in the function. Is there another way how I could do that without using p and t in parameters or if I'm calling a function in a function I must use the values ?
It's usually a good idea to separate computation from presentation. In other words, compute your results in one place and present them to the user somewhere else:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
...
void print(float e, constchar *fileName)
{
ofstream out(fileName);
out << "Paul spends per month: " << fixed << setprecision(2) << e << " euros"\
<< endl;
}
int main()
{
int p, t;
read(p, t);
float expenses = spendsForLiving(p, t);
print(expenses, rez);
return 0;
}