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
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
From C to shining C++!
Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
- Bubba
IDE and Compiler - Code::Blocks with MinGW
Operating System - Windows XP Professional x64 Edition
Thank you very much!