Тема: Чому програма не записує дані в файл?
Доброго дня! Маю завдання створити програму яка буде обчислювати суми нескінченного ряду(з цим завданням я ніби впоралась), а результати записувати в файл, але файл чомусь залишається порожнім... Допоможіть, будь ласка розібратись у чому помилка...
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma argsused
#include <tchar.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
 #include <fstream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
SetConsoleOutputCP(1251);
SetConsoleCP(1251);
int k=1;
double x,f,result,equation,e=0.001,fact=1;
cout<<"Введіть значення х від (0 до 1)"<<endl;
cin>> x;
do{  f=cos(pow(x,3))/2.4+cos(pow(x,2))/2.4-9.46;
    equation=pow(-1,k)*(f*(sin(3*x+1))*(2*k+1)*pow(x,k))/fact;
    k++;
    fact*=k;
    result+=  equation;
    cout<<"k="<<k-1<<"\t Сума="<< result<<endl;
}
while(fabs( equation)>=e);
   cout<<endl<<"Сума ряду="<<result;
   cout<<endl<<"Для досягнення точності "<<e<<" необхідно "<<k-1<<" доданків " ;
   system("pause");
   string path="file.txt";
ofstream fout;
fout.open(path);
 if(!fout.is_open())  {
    cout<<"Помилка"<<endl;
 }
 else{
       fout <<"Сума ряду="<< result ;
       fout <<"Для досягнення точності "<<e<<" необхідно "<<k-1<<" доданків " ;
 }
 fout.close();
 return 0;
}