My program has to load a file named "x" everytime it is executed.(not from the command line,but from the directory it is in)The first time it is executed there exists no such file,but on the further executions there exists.How can I do this job?
Printable View
My program has to load a file named "x" everytime it is executed.(not from the command line,but from the directory it is in)The first time it is executed there exists no such file,but on the further executions there exists.How can I do this job?
//If the file doesn't exist, fstream will create it.
#include <iostream.h>
#include <fstream.h>
int main()
{
char buffer[100];
ifstream FileReader("C:\\whatever.txt");
FileReader>>buffer;
cout<<"whatever.txt: "<<buffer<<"\n";
FileReader.close();
return 0;
}