I'm making a program where the user type in a file name and opens the file.
This is what I did, but it's not working.
What do I do?
Plz help thx.
Code:#include <iostream> #include <string> #include <fstream> using namespace std; // Function prototypes int main() { char name[20]; char name1[20]; cout << "Please enter the filename of the encoded message:"; cin >> name; cout << "Please enter the known word:"; cin >> name1; ofstream outfile; outfile.open(name); ifstream infile; infile.open(name); if (infile.fail()) { cout << name << " fail to open." << endl; exit(1); } outfile.close(); return 0; }