Problem getting user to enter txt file.
I am currently writing a program that requires the user to enter the file name for the .txt file. I'm sure I'm just missing something simple. Below is the code.
cout << "Please enter file name: ";
cin >> textName;
textName += ".txt";
// opening txt file.
// reads in data from file
Unless your compiler supports C++11 where you can pass a string into an fstream constructor you need to pass it as a C style string instead.
Thank you James, you solved my problem. Have a great night sir.
Topic archived. No new replies allowed.