#include<conio.h>
#include<iomanip>
#include<cmath>
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
fstream afile;
afile.open("example.txt");
afile<<"Hi I am Unnat";
afile.close();
string line;
ifstream myfile ("example.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
cout << line << '\n';
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
The output i get here is always Unable to open file and when i check the folders I dont find example.txt Please help.