I have created a section in my program such that it will prompt user to enter the filename. From this, it will create the file with the filename the user have entered.
However, I would like to know how can I check if the file already exists? If it already exists, do not create the file and simply open the existing file and add more data from the last line.
Here's part of the code
cout << "Enter filename: ";
cin >> pfile;
/* open an existing configuration file to check if the filename exists
(I'm not sure how to check... this simply open the file) */
infile.open("config.cfg", ios::in, 0);
// create file base on what user specify
// open configuration file and store filename in it
outfile.open("config.cfg", ios::out, 0);
outfile << pfile;