I am trying to open a file with a program but it keeps failing. I typed the file into notepad and saved it as a .dat file. Does anyone have any ideas why this is happening?
Code:#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
string filename = "bank.dat";
ifstream inFile;
inFile.open(filename.c_str());
if(inFile.fail())
{
cout<<"\nThe file named "<<filename<<" was not successfully opened"
<<"\nPlease check that the file currently exists."
<<endl;
exit(1);
}
cout<<"\nThe file has been successfully opened for reading."
<<endl;
return 0;
}