I am using fstream.h, and I want the user to be able to name the file. But it is in a string literal? and I don't know how I can have them name it? Is this possible?
JDM
Printable View
I am using fstream.h, and I want the user to be able to name the file. But it is in a string literal? and I don't know how I can have them name it? Is this possible?
JDM
Yes, it is possible.
There you go.Code:#include <iostream>
#include <fstream>
#include <string>
int main( void )
{
std::string Name;
std::cout << "What is the file name? " << std::endl;
std::getline( std::cin, Name );
std::ofstream fOut( Name.c_str() );
fOut << //Put in stuff
fOut.close();
return 0;
}
- SirCrono6
Thank you very much! :)