I'm trying to get a handle on basic file i/o and am totally stuck. This is the code - it complies with no errors or warnings but fails when run with the input file .open fail message. I'm using visual studio 2010 on a Vista laptop. I've tried using the full path of a specially set up directory C:/C++Files but that doesn't work.
I guess this is an old favorite but a search did not help. Any assistance much appreciated.
using namespace std;
int test1 =0, test2 =0, test3 =0;
cout<<"Input file opening failed"<<endl;
cout<<"Output file opening failed"<<endl;
An ifstream by default won't open a non-existing file, but if you use the std::ios::app flag it will create the file if it doesn't exist. I do agree that creating an empty file for reading isn't very useful but it can be done.