I'm trying to make a calculator which when run opens a txt file form a certain path, the user inputs the data and when the user closes said txt file the rest of the program runs. I have 0 ideea how to open files in c++ or how to detect whether said file is running or not.
#include <fstream>
//1.card's attacks stat
//2.the rest of the multipliers (the defensive calculations are much easier then the attack stat calculations so this is possible)
using namespace std;
double stats[16];
int main()
{
//in theory what this does is opens the txt file, allows the user to enter the data and then closes.
system("D:\atk stat\def stat v2\template.txt");
ifstream fin("template.txt");
//from this point on it's just the calculator stuff
int n,i,finstat;
double x;
finstat=1;
//reads the data
n=0;
while(fin>>x)
{
n++;
if(x==0)
stats[n]=1;
else
stats[n]=x;
}
//transforms all the buffs into multipliers
for(i=2; i<=n; i++)
if(stats[i]!=1)
stats[i]=(stats[i]/100)+1;
//multiplies everything to the cards DEF stat
for(i=1; i<=n; i++)
{
finstat=finstat*stats[i];
}
//this just prints out the DEF stat
cout<<finstat<<endl;
return 0;
}